I'm using guideBridge.validate([], <some-expression>) and I've expected that children of other panels than the one identified with the SOM-expression would not be validated (as described in Doc). But that's not case.
var result = [];
guideBridge.validate(result, <some-expression>) ;
Result will only contain errors referring to children of the node identified by <som-expression>. But in the DOM all fields of the form, whose validation fails, will be updated (with css class 'failure').
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Yes, you can add these scripts as clientlib. If you want to run scripts on an event ( eg - click of a button), you can add them through the script tab of the edit dialog of that component.
Views
Replies
Total Likes
I am why this should happen. API is supposed to work for the SOM provided. Can you please share the collateral and the script you are trying. Also what release of AEM Forms are you on ?
Views
Replies
Total Likes
I'm working with AEM 6.1 and Hotfix adobe-aemds-native-x86-win32-pkg-2.2.4.zip installed.
The function looks like this:
function customizedValidate() { ... var errors = []; if(guideBridge.validate(errors, somExpression)) { ... } ...
The errors array will only contain messages referring to widgets that are children of the widget (or panel) specified by the somExpression.
But: On widgets that are children of different parents (more specific: siblings of the one specified by the somExpression) the css class 'validation-failure' is still set and the div.guideFieldError of the div.guideFieldNode will contain the error message.
Views
Replies
Total Likes
Hi,
On using the validate API, the fields specified in the validate API get the class "validate-failure" only if the field does not pass the validate test. Probably, in your case, there must be a call to validate the entire AF before the actual validate to the field is called.
To verify this, you can perform the following steps:
a) Open the AF in preview mode.
b) Once done, before doing any changes in AF, execute the below mentioned script.
c) Say the som expression of the field to validate is "A", then in the browser console, execute this javascript,
var errors = []; guideBridge.validate(errors, "A");
d) Only the field "A" in AF should have the validation-failure class and not the other fields.
Let me know if you have further doubts/queries.
Thanks
Views
Replies
Total Likes
Hi Rishi
I've retested following your instructions and I haven't found any "validation-failures" markers in other panels than the one specified.
So, I guess you were right and in the case of the "error" I reported there was another call before my custom validation that validated all panels.
Thanks,
Urs
Views
Replies
Total Likes
Hi Rishi,
How can we invoke custom validations on AF fields, I tried to check text field input data is matching email format or not by writing custom method.
But if user click on submit button my custom validations not working. How can we invoke our custom validate method and display error messages when user click on submit
Can you share any sample code how to call use validate method.
My code:
window.addEventListener("bridgeInitializeStart", function(evnt) {
gb.connect(function (){
gb.on('elementValueChanged', function(event, data) {
var elementName = data.target.name;
var elementValue = data.target.value;
var elemenText = data.newText;
var elementNameUppercase = elementName.toUpperCase();
if(elementNameUppercase == 'EMAIL'){
if(!validateEmail(elementValue)){ // calling email validation method
console.log("Email is not valid");
list = [{som:data.target.somExpression,errorText: "Email is not valide"},
{som:data.target.somExpression,errorText: "Email is not valide2"}];
}
}
if(elementNameUppercase == 'NAME') {
console.log('this is name field');
}
});
gb.on('elementButtonClicked', function(event, data) {
gb.validate(list, null); // this method calling not working
});
})
});
Views
Replies
Total Likes
I am very new to form. May be a silly question, but where we are suppose to write this piece of code ? Is it in clientlibs ?
Views
Replies
Total Likes
Hi,
Yes, you can add these scripts as clientlib. If you want to run scripts on an event ( eg - click of a button), you can add them through the script tab of the edit dialog of that component.
Views
Replies
Total Likes
Hi,
Yes, you can add these scripts as clientlib. If you want to run scripts on an event ( eg - click of a button), you can add them through the script tab of the edit dialog of that component.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies