-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex validation rule not working as expected #3313
Comments
I'm also having an issue with regexp validation. This regexp : regExp[/^+[0-9]{11}$/] I have that message in web console : I think that your unvalid form is not due to your regexp but to semantic-ui form regexp rule handler |
I'm also having regex validation issues with dates. |
Is there a solution to this issue? |
+1 |
Don't forget to double escape all the things. //d not /d for a digit for example. |
Can someone give me a simple js regexp that is not evaluating correctly? I would love to fix |
Hi @jlukic, I don't remember exactly, but the problem is not regex, but mixing short rules and complet rules. There is a thread mentionning that |
Having the same issue here, but with an string: RegExp String Regular expression tested here... Where's the issue? |
I'll try to look over this as the last issues to put into |
Have you double escaped that? Sent from my iPhone
|
I had a similar issue with date validation but double escaping fixed it. Is this mentioned anywhere in the docs? |
It is touched on, I think, although I cant find it for looking now. I think I googled my way to an answer* on it but thought it would be good to leave it somewhere further up the google trail.
You’d figure it out eventually though because it’s taking a string to pass a function that will run the regex so after a bit of head scratching it makes sense it should be re-escaped.
|
I was about to post an issue, having a hell of a time validating a phone number (which can be difficult in a lot of settings...) DOUBLE ESCAPE special characters. ex. thanks @Iheff |
I've added a new syntax to make it simpler to pass in regular expressions Instead of using bracketed notation, you can now pass in a $('.ui.form').form({
fields: {
color: {
identifier: 'color',
rules: [{
type: 'regExp',
value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/i,
}]
}
}
}); This is the only solution I could think of, as once the regexp is encoded as a string it is impossible to infer the original intention for escaped bracketing. |
I've also added this specific example to usage section of form validatio to make it more clear. |
Thanks @jlukic ! I think this makes the validation a little more intuitive. |
I'm having an unusual issue with a regex validation rule. It seems to work in some cases, however I'm trying to use it to validate a date however it's saying that the date is not valid, even though it is.
http://jsfiddle.net/efp8z6Ln/260/
This fiddle shows an input field with a valid date value being validated using a regex. The regex itself works as demonstrated, and matches what it should, yet the form validation still returns false.
The text was updated successfully, but these errors were encountered: