Hi All,
I'm trying to compare 2 number fields in content fragment through custom js. So based on that validation I'll have to display an error message. So for that I'm making use of Granite.I18n.get.
Can anyone help me in setting up the Granite.I18n.get message to a specific field in content fragment ?
Thanks in Advance!
Solved! Go to Solution.
Views
Replies
Total Likes
The granite.utils client library folder provides the JavaScript API. To use the API, include this client library dependency in your custom clientlibs.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="custom.clientlibs"
dependencies="[granite.utils]"/>
Localization functions use the Granite.I18n namespace.
Before you present localized strings, you need to set the locale using the Granite.I18n.setLocale function. The function requires the language code of the locale as an argument:
Granite.I18n.setLocale("fr");
To present a localized string, use the Granite.I18n.get function:
Granite.I18n.get("string to localize");
@priyak Please check the example given by @BrianKasingli for content fragment validation in the below post
Hi @Saravanan_Dharmaraj Thanks for the reference but I have already checked that post, In my case I'll have to compare 2 number fields and validate.
For the first approach:
I was able to write custom JS for the same but I'm facing issues while increasing/decreasing value through scroller(mousepad) since it is number field.
For the second approach:
I was trying to implement error message through this Granite.I18n.get(since same is being used for OOTB validations in content fragment) but I'm unable to set that error to a specific field.
Any help would be appreciated.
The granite.utils client library folder provides the JavaScript API. To use the API, include this client library dependency in your custom clientlibs.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="custom.clientlibs"
dependencies="[granite.utils]"/>
Localization functions use the Granite.I18n namespace.
Before you present localized strings, you need to set the locale using the Granite.I18n.setLocale function. The function requires the language code of the locale as an argument:
Granite.I18n.setLocale("fr");
To present a localized string, use the Granite.I18n.get function:
Granite.I18n.get("string to localize");
Views
Like
Replies
Views
Likes
Replies