I need to have 2 or more buttons in a FORM and each with a different action, I know that I can do this directly with HTML by adding a formaction but I need to do this from AJAX , I am also aware that I can use a onclick on each button, but I need it to be submit so that html is in charge of doing all the validations of the form, since there are fields with the required attributes, maxlength, email, number, etc.
It would be something like this that I need:
$(function(){
$('form').submit(function(event){
event.preventDefault();
/*Codigo Ajax*/
});
});
<form>
<input type="text" name="usuario" required/>
<input type="password" name="password" required/>
<button formaction="login.php"></button>
<button formaction="registro.php"></button>
</form>