Is there a method to use the Granite UI's validation service to actually stop a form from being submitted?
For example: I want to validate a field named tabAnchor against a regex. I produce the following javascript, leveraging the Granite API.
(function($, Granite) { "use strict"; var unitPattern = /^[a-zA-Z][a-zA-Z0-9]*/; /** * A validation for tabAnchor */ $.validator.register({ selector: '.field-tabAnchor', validate: function(el) { var valid = unitPattern.test(el.val()); if (!valid) { return Granite.I18n.get("Must be valid tabAnchor name"); } } }); })(Granite.$, Granite);
This creates a warning triangle that has an error message when you mouse over it. However, this does not prevent me from submitting invalid data.
I have experimented with various placements of preventDefault/stopPropagation with no success. Any help is welcome.
Solved! Go to Solution.
Views
Replies
Total Likes
You may have to write your custom logic to do the same.
Keep a count of errors if you have any in the form and disable the 'submit' button until you have count zero.
Views
Replies
Total Likes
We have asked internal team to look at this.
You will sooner get some help on this.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
You may have to write your custom logic to do the same.
Keep a count of errors if you have any in the form and disable the 'submit' button until you have count zero.
Views
Replies
Total Likes
Hi
As mentioned by Lokesh, you need to write a custom logic to so the same.
Reference links:- http://www.nateyolles.com/blog/2016/02/aem-touch-ui-custom-validation
http://adobeaemclub.com/aem-touch-ui-dialog-validation/
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies