0

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.

3 Answers 3

1

Try this:

<input name="username" type="text" class="newtextbox required" digits="true" min="4" max="16">
Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

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.
I could not get it work work. I get NaN. I am only using the Javascript from the documentation like above.
0

This is a bug in the plugin. See https://github.com/jzaefferer/jquery-validation/issues/447 for a patch.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.