Search code examples
javascriptjqueryvalidationinputpreventdefault

How to prevent the default browser input validation?


I have a simple form with phone inputs and some email inputs, however I cannot get rid of the default browser warning messages that come up when I click the submit button.

enter image description here

My CodePen

I've tried to implement event.preventDefault(); however it doesn't seem to work in my case.

$('#profile-info-form').unbind('submit').bind("submit", function(event) {
    event.preventDefault();
    console.log('save button clicked');
});

Example of the input fields I create on the fly:

var myphone = "<li><label>Cell Phone:</label></li><li><input type='tel' pattern='[0-9]{10}' class='added_mobilephone' name='mobilephone' value='' autocomplete='off' maxlength='20' /></li>";


How would you handle this problem?


Solution

  • Remove the pattern attribute? Just using the tel type should still get you the keypad interface on mobile and without pattern the native validation/formatting should not run.