How convert single line text to decimal for 4 variables in one client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:45 PM
Hi
I have a requirement
i have 4 variables
Questions | type | |
Height | Decimal (0.000) | |
Width | Decimal (0.000) | |
Length | Decimal (0.000) | |
weight | Decimal (0.000) |
How to convert single line text variables into Decimal in one client script.
and when the user entered not decimal show a filed error as "please enter decimal value 0.000"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:53 PM
Hello @Raveendra7
var regex = (\.[0]{1,4})?$ ;
if(!regex.test(newValue)){
gs.info('your message')
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 04:14 AM - edited 08-04-2023 04:17 AM
i want this script work for remaining 3 variables in single script
g_form.getValue('Width');
g_form.getValue('Lenght');
g_form.getValue('weight');
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var myVal = g_form.getValue('Height');
var matchPattern = /^\d{4}[.]\d{2}$/;
var myResult = matchPattern.test(myVal);
if(!myResult){
g_form.clearValue('Height');
g_form.showFieldMsg('Height','Required format is xxxx.xx','error');
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 04:26 AM
Hello @Raveendra7
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var myH = g_form.getControl('Height');
var myW = g_form.getControl('Width');
var myL = g_form.getControl('Length');
var matchPattern = /^\d{4}[.]\d{2}$/;
if(myH.changed){
if(!myH.test(matchPattern)){
g_form.clearValue('Height');
g_form.showFieldMsg('Height','Required format is xxxx.xx','error');
}
}
if(myL.changed){
if(!myL.test(matchPattern){
g_form.clearValue('Length');
g_form.showFieldMsg('Length,'Required format is xxxx.xx','error');
}
}
if(myW.changed)
if(!myW.test(matchPattern){
g_form.clearValue('Width');
g_form.showFieldMsg('Width,'Required format is xxxx.xx','error');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 10:52 AM
Hello @Raveendra7
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh