Captain0
Captain0

Reputation: 2623

jquery Validation works half way

Hi I am struggeling with the jquery validation.

I have a requirement to draw a form dynamically. Depending on the parameters that the users set up. I have to validate these input fields then when the user submits this form. I got it working by adding the class='required' to all the inputs that i want to validate.

This works 80%, it validates the first 6 fields on the page, but not the rest. On the fields that is not validated on form submit, i just need to click in the input with my mouse and then leave the input again, then the validation is fired.

Am i missing something with the validation.

Here is how i determine when/when not the field should be validated.

@Html.TextBoxFor(x => param.SelectedDate, new {@class = (!param.IsNullable) ? "required" : "", @id = param.Parameter.Name, coltype = "date" })

Like I Said it works, just not on the form submit, and not for all the fields.

please help

Upvotes: 0

Views: 243

Answers (1)

rkw
rkw

Reputation: 7297

This may be the same issue I had awhile back: Trouble getting unobtrusive validation working with mvc 3 on jquery ajax post

You may have to rebuild the validators since you added controls dynamically:

$.validator.unobtrusive.parse($('form'))

Upvotes: 1

Related Questions