This is a migrated thread and some comments may be shown as answers.

Form Validation on Button Click

1 Answer 532 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 19 May 2015, 08:30 PM

Hi,

 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 http://dojo.telerik.com/AXIsI/2

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

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 May 2015, 01:05 PM
Hi,

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(){



Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Validation
Asked by
Raja
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or