Search code examples
htmlvalidation

How to disable messages from of HTML validation but keep validation enabled


I need to disable only the error message of HTML Validation; the actual validation should still be there. User won't submitted the form without filling text field. Even if the user does not fill in a required text field, I don't want to display any message like "Please fill out this field".

<form action="action_page.php">
  First name:<br>
  <input type="text" name="firstname" value="" required>
  <br>
  <input type="submit" value="Submit">
</form> 

Solution

  • You can use novalidate attribute to skip validation from HTML and then add validation code on javascript - on submit event.

    HTML:

    <form novalidate>
      First name:<br>
      <input type="text" name="firstname" value="" required>
      <br>
      <input type="submit" value="Submit">
    </form> 
    

    JS:

    $('form').submit(function(){
        //check validations and submit through AJAX
        return false;
    });