Form Validation on Button Click

2 posts, 0 answers
  1. Raja
    Raja avatar
    47 posts
    Member since:
    Oct 2013

    Posted 19 May 2015 Link to this post


     I have a form with validations setup and everything works fine if user tries to enter something. If user directly clicks on the submit button after page load with out touching any field then validations wont fire.

     Take a look at the example here

    if you just go into the text box and tab out, then error message is displayed. if you directly click on the button with out touching then validation message is not displayed as the rules is skipped based on input name checking. How can make this work?

     I made the example to be simple, in real scenario there is so much complex logic involved. So I cannot avoid using check on name and also I cannot use just the html5 "required" attribute

  2. Daniel
    Daniel avatar
    2231 posts

    Posted 21 May 2015 Link to this post


    The validator will automatically validate the inputs when a submit button is clicked if it is initialized on a form. If a <div> element is used then you should manually call the validate method which will not happen with the code that you provided because the button does not have "btnSubmit" ID:
    <input name="btnSubmit" type=submit />
    $("#btnSubmit").on("click", function(){

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top