Reputation: 2550
I am working on MVC4 project where i have textbox in which i have to enter max 5 numbers but those number could be -ive or +ive
So i am using custom jquery validation but this is not satisfying the requirement here is validation expression i am using
"onlyNumberSp": {
"regex": /^[0-9]+$/,
"alertText": "* Numbers only"
},
I know this is not correct expression so how can i achieve this functionality where user can enter max of 5 numbers with - or + or may not enter any sign.
Upvotes: 0
Views: 1320
Reputation: 1320
"onlyNumberSp": {
"regex": /^-?\d{1,5}$/,
"alertText": "* Numbers only"
},
Upvotes: 2