Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 928
Leon Gaban Avatar asked Aug 01 '13 14:08

Leon Gaban


1 Answers

If you want to disable client side validation for a form add a novalidate attribute to the form element. Fx:

<form method="post" action="" id="profile-info-form" novalidate>

 // Your script Here

 </form>

See http://www.w3.org/TR/html5/forms.html#attr-fs-novalidate

like image 179
Pank Avatar answered Oct 05 '22 19:10

Pank