Discussion:
[jQuery] “(validate)”
Søren gruby
2010-02-04 13:28:34 UTC
Permalink
I'm using the jQuery plugin: Validation.

How can I validate, say a textbox inside a specific div element that
has a specific id?

$(document).ready(function() {
$("#aspnetForm").validate({
rules: {
txt_1: {
minlength: 2,
required: true
},
txt_2: {
required: true,
email:true
}
}, messages: {}
});
});

I have a textbox in a div with an id = "testdiv" and the above code
doesn't seem to locate the textbox.

Thanks
Nathan Klatt
2010-02-04 14:43:05 UTC
Permalink
Post by Søren gruby
How can I validate, say a textbox inside a specific div element that
has a specific id?
Validate validates forms so to validate a field, it has to be in a
form - doesn't matter whether it's in another div or what. Each rule
entry refers to a field's name.
Post by Søren gruby
From your example, it looks like you have a form with id="aspnetForm"
but you don't specify what your input's name is; if it isn't txt_1 or
txt_2 then it won't be validated.

You can find some samples here:

http://jquery.bassistance.de/validate/demo/

Nathan

Continue reading on narkive:
Loading...