? Success

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
5 Dec 2016

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#L13
Create a new article and try to submit without a title or with title as 87587676 (or anything apart english alphabet letters)

screen shot 2016-12-05 at 16 35 31

@Fedik @ggppdk @mbabker


This change is Reviewable

avatar dgt41 dgt41 - open - 5 Dec 2016
avatar dgt41 dgt41 - change - 5 Dec 2016
Status New Pending
avatar dgt41 dgt41 - change - 5 Dec 2016
Labels Removed: ?
avatar dgt41 dgt41 - edited - 5 Dec 2016
avatar joomla-cms-bot joomla-cms-bot - change - 5 Dec 2016
Category JavaScript
avatar dgt41 dgt41 - change - 5 Dec 2016
The description was changed
Labels Removed: ?
avatar dgt41 dgt41 - edited - 5 Dec 2016
avatar Fedik
Fedik - comment - 10 Dec 2016

works good ?
but I think better to change as @ralain sugested

avatar ralain
ralain - comment - 10 Dec 2016

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:

isValid = new RegExp('^'+$el.attr('pattern')+'$').test($el.val());

avatar dgt41 dgt41 - change - 15 Dec 2016
Labels Added: ?
avatar dgt41
dgt41 - comment - 15 Dec 2016

@Fedik @ralain I've pushed the suggested code

avatar ralain
ralain - comment - 15 Dec 2016

I have tested this item βœ… successfully on 73c97f8

HTML5 pattern and JS validation match up perfectly, now. Thanks for this.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13094.

avatar ralain ralain - test_item - 15 Dec 2016 - Tested successfully
avatar Fedik
Fedik - comment - 18 Dec 2016

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.

avatar Fedik Fedik - test_item - 18 Dec 2016 - Tested successfully
avatar zero-24 zero-24 - change - 18 Dec 2016
Milestone Added:
avatar zero-24 zero-24 - change - 18 Dec 2016
The description was changed
Milestone Added:
Status Pending Ready to Commit
Labels Added: ?
avatar zero-24 zero-24 - edited - 18 Dec 2016
avatar rdeutz rdeutz - reference | 52d8bc0 - 18 Dec 16
avatar rdeutz rdeutz - merge - 18 Dec 2016
avatar rdeutz rdeutz - close - 18 Dec 2016
avatar rdeutz rdeutz - change - 18 Dec 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-12-18 12:38:02
Closed_By rdeutz
Labels
avatar rdeutz rdeutz - close - 18 Dec 2016
avatar rdeutz rdeutz - merge - 18 Dec 2016
avatar dgt41 dgt41 - head_ref_deleted - 18 Dec 2016
avatar cpfeifer cpfeifer - reference | fb3e6ba - 22 Dec 16
avatar minijoomla
minijoomla - comment - 17 Nov 2017

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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 17 Nov 2017

@minijoomla is this similar to #18591?

Add a Comment

Login with GitHub to post a comment