I am using the jQuery Validation plugin
I want one of my fields to be a number, but it is not a required field.
The thing is, when I set number: true, it makes the field required. Why is that? I tried to add required: false with number: true, but to no avail.
This my code:
name : {
required:false,
number:true
}
I am not setting an error message, but it shows the default error message: “please enter a valid number.”
In the source code they are using this regex to validate a number:
When the field is empty(
""), it does not pass the test: