Bootstrap Validator - RegExp weird behavior
Bootstrap Validator - RegExp weird behavior
I have to validate a field that allows just words, spaces, and the characters "&" and "-".
The regex I'm using is /[A-Za-zsb-&]+/g.
/[A-Za-zsb-&]+/g
Here is the code:
$('#register_validator').bootstrapValidator({
framework: 'bootstrap',
fields: {
name:
validators:
regexp:
regexp: /[A-Za-zsb-&]+/g,
message: 'Invalid character'
When I write a valid string and then I erase a character, it triggers the validator.
For example:
text: Jones -> OK
erase a char: Jone -> message: Invalid character
Is there something wrong with the regEx? What can I do to avoid this bug?
1 Answer
1
I've solved the problem with /^[a-zà-ús-&üû]+$/i
/^[a-zà-ús-&üû]+$/i
It allows the alphabet, extended chars, spaces and the special chars & and -.
&
-
Thanks!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.