Vicky
Vicky

Reputation: 9575

Jquery Validation

Is there is any way to validate form using jquery on dynamic fields.

I want to make it required fields

I am creating form fields dynamically using Jsp.

like

<form name="myForm" id="myForm">
<input type="text" name="name1" value="">
<input type="text" name="name2" value="">
<input type="text" name="name3" value="">
<input type="text" name="name4" value="">
</form>

so on....

I want to validate this form fields with required form field.

Upvotes: 2

Views: 840

Answers (2)

IsmailS
IsmailS

Reputation: 10863

Have a look at this jQuery plugin: Validation , its demo and the view source. I think you can also generate this little javascript dynamically with your form fields.

Upvotes: 3

Davide Ungari
Davide Ungari

Reputation: 1960

You could "tag" your form element with a class name like "required" in JSP. Then onSubmit you can check if any $(".required",form) has empty value.

Upvotes: 2

Related Questions