Sachin Singh

Sachin Singh

  • 7
  • 55.8k
  • 82.8k

Html 5 required validation with ajax without refreshing the page.

Jul 31 2020 1:39 AM
I know to use Html 5 validation with ajax we generally use submit event handler and not button with preventDefault click like below
  1. <form method="post" id="subsForm">  
  2. <div class="input-group">  
  3. <input type="email" required>  
  4. <input type="submit">  
  5. </div>  
  6. </form>"  
  7. $('form').submit(function(event){  
  8. event.preventDefault();  
  9. $.ajax(){  
  10. // submit data to controller  
  11. }  
  12. });
Ok , thats a good solution to force Html 5 validation to work without submitting the form but it violates the definition of Ajax and causes to refresh the page when page is submitted with satisfied validations.
 
Is there any solution till date to use html 5 validations without page refresh.

Answers (6)