views:

250

answers:

2

Hi,

I'm using the jQuery Validator Plugin. My code is like this:

<input name="username" type="text" class="newtextbox required" rangelength="(4,16)">

The error message is "Please enter a value between NaN and 4 characters long". The actual error message that has to be is "Please enter a value between 4 and 16 characters long".

I think the HTML I have used is incorrect.

Can anyone help me out? Thanks in advance.

A: 

Try using square brackets instead:

<input name="username" type="text" class="newtextbox required" rangelength="[4,16]">

Still, you shouldn’t be defining this inside the HTML; you can do this with JavaScript.

$("#some-form").validate({
 rules: {
  field: {
   required: true,
   rangelength: [4, 16]
  }
}

});

You can read more about the rangelength method of the jQuery Validation Plugin if you wish.

Mathias Bynens
Thank you Mathias. I am using jquery.validator.js. There is already a option to use rangelength for the validation but the problem is how to use this in html. Hope you get what i mean. Thanks again.
Have you tried using square brackets, as I suggested?
Mathias Bynens
A: 

try this <input name="username" type="text" class="newtextbox required" digits="true" min="4" max="16">

entraigas