Hi, in this dojo, http://dojo.telerik.com/@ximnet/iciqu, I am trying to validate the form when the submit button is clicked.
However I get error 'Uncaught TypeError: undefined is not a function'
Is this the correct way to validate a validator?
Thanks.
3 Answers, 1 is accepted
0
Rosen
Telerik team
answered on 29 Oct 2014, 02:04 PM
Hi,
The error is thrown due to the fact that the form_validator variable is referencing the jQuery wrapped DOM element not the Validator widget, thus it does not have validate method. In order to get reference to the widget you may use the getKendoValidator method:
Also note that as the Validator is attached to a form element, the validation will be executed automatically when the form is submitted, which in this case is when the button is clicked. Therefore, there is no need to manually call the validate method.
If you want to execute some custom logic, for example show an alert to the user, when form is validated you may use the validate event.
Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
I have updated my code with the validate event but it does not seems to fire the event when click on register button.
http://dojo.telerik.com/@ximnet/iciqu
When I try with a type="submit" button then it can work.
Is there a way to make it work without specifying the button as submit type?
Thanks
0
Accepted
Rosen
Telerik team
answered on 31 Oct 2014, 08:08 AM
Hello,
As I have mentioned in my previous message, the automatic validation of the form will happen only when the form is submitted. In the sample you have provided the register button will not submit the form as it is not a submit button, therefore you will need to use the validate method to trigger the validation.
Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!