Skip to content Skip to sidebar Skip to footer

Jquery Validator Plug In - Trigger From Within A Function

I am having trouble validating a long form that is loaded via AJAX after the document is loaded. Using the standard validation syntax, the validator looks for my form in the docume

Solution 1:

You've likely got the problem right. If the form doesn't exist in the DOM at document.ready(), then nothing will be bound.

Since you're using JQuery, I presume the form is added using the jquery $.ajax (or similar) function. The most straightforward solution would be just to add $("#mainForm").validate(); to the callback function of the AJAX request. If you're not using JQUery ajax, please post the code that's adding the form, and we can help you out further.

Solution 2:

you have to specify the class definition to element as required for it to validate that particular element in the form. But I guess you are not having it anywhere so its showing like that.

for example if you want to validate the email:

<p><labelfor="cemail">E-Mail</label><em>*</em><inputid="cemail"name="email"size="25"class="required email" /></p>

Solution 3:

Simple mistake in selector "mainform" is not a valid selector. Add "#" prefix if it is an ID

EDIT: Also notice you have another validate call inline , remove that one

Post a Comment for "Jquery Validator Plug In - Trigger From Within A Function"