-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HTML5 pattern in validate.js #13094
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
HTML5 pattern in validate.js #13094
Conversation
ralain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure it's not going to work with a regex literal. You might try something like this, instead:
isValid = new RegExp($el.attr('pattern')).test($el.val());
|
works good 👍 |
|
Looked into this further and as I suspected you can't use a variable in a JavaScript regex literal. The variable itself (not its value) becomes the pattern. Also, html5 pattern and JS regex are not fully compatible, but it's fixed easily by adding start and end of string, like so:
|
Thank you @ralain
|
I have tested this item ✅ successfully on 73c97f8 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13094. |
|
I have tested this item ✅ successfully on 73c97f8 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13094. |
|
Hi, this pull has a problem with unrequired inputs. test: a field that is not required but has pattern to be a number or other . when user not enter value for this input and submit, validation say that field is not correct |
|
@minijoomla is this similar to #18591? |
Pull Request for Issue #12857 .
Summary of Changes
HTML5 NATIVE validation is done through
pattern="something"The validate.js is adjusted so if pattern tag exists will take precedence else we fall back to the rules
Testing Instructions
Add
pattern="[a-zA-Z]+"after https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_content/models/forms/article.xml#L13Create a new article and try to submit without a title or with title as 87587676 (or anything apart english alphabet letters)
@Fedik @ggppdk @mbabker
This change is