Im trying to hook up some validation for a site that im doing … i have to admit, im not a jquery ninja.
So what i have done is taken validation from another site and added it to my site but it doesnt seem to be working.
My HTML is as follows
<label for="yourname">Your name</label>
<input type="text" name="yourname" id="yourname" /> <span class="error" style="width: 180px;"></span>
and a small fraction of the jquery that im using to validate is as follows:
if(!isString($.trim(iName.val()))){
iName.siblings('.error').text('Please enter your name.');
error = true;
}
The bit that its getting stuck on it the siblings bit … when i run the code, it puts the error text behind every .error span on the page, where its only meant to put it on the .error span behind the current element.
Any help would be great.
Cheers
1 Answer