Using HTML5 Pattern for form field validation, how does one stop a submission if the form is invalid? Maybe I should ask, how does one create a custom valid/invalid form handler?
Documentation on the changePage()
$('#form-submit-button').click( function() {
event.preventDefault(); // This is undefined
// This submits my form and values via ajax, handles page transition
$.mobile.changePage({
url: 'request.php?page=one',
type: 'post',
data: $('form#test_form').serialize()
},'slide',false,false);
});
Example HTML Form Field
<input type="text"
name="first_name"
id="first_name"
placeholder="First Name*"
pattern="[\w .-]"
required />
Example HTML Button (Not Submit type)
<input type="button"
data-theme="z"
data-icon="forward"
data-inline="true"
name="form-submit-button"
id="form-submit-button"
value="Next Step"/>
http://marxsoftware.blogspot.com/2011/01/html5-form-field-validation.html
According to this, it shouldn’t let you submit your form till it validates.