-
Type:
Improvement
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.0.x, master, master-deprecated, 3.0.x, 2.0.0.64-deprecated, 3.1.x
-
Component/s: Form Validator
-
Labels:None
-
Git Pull Request:
Nowadays it's hard to know how to add custom rules to the form validator since you need to add a new property to the config object.
Y.config.FormValidator.RULES.imageURL = function(val) { var regex = /(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/i; if (regex.test(val)) { return true; } else { return false; } } Y.config.FormValidator.STRINGS.imageURL = 'Please enter a valid URL that points to an image (jpg, jpeg, png, or gif).'; var form = new Y.FormValidator({ boundingBox: '#form', rules: { 'image-url': { imageURL: true, required: true } } });
Developers who are not used to check AlloyUI's source code might not find how to achieve that.
Would be nice if we could provide a better API for custom rules.
- relates
-
LPS-50980 Character count for textarea element input in Char Counter is incorrectly calculated in Chrome
- Closed