- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2017 10:54 PM
Hi Experts, Good Day !
Can you please let me know how can I check value which is between 2 numbers using catalog client script
Ex. Suppose I have a variable caller emp_age on catalog item so if value for this variable is greater than 10 and less than 19, an message should pop up like "Employee is underage" .
I have written below script but it is not working as expected. If I am entering value 20 for emp_age field, in that case also I am getting a alert like "User is underage".
Thank you in advance !
unction onSubmit() {
//Type appropriate comment here, and begin script below
var agee = g_form.getValue('u_age');
switch (agee) {
case 0:
alert('User is underage');
break;
case 1:
alert('User is underage');
break;
case 2:
alert('User is underage');
break;
case 3:
alert('User is underage');
break;
case 4:
alert('User is underage');
break;
case 5:
alert('User is underage');
break;
case 6:
alert('User is underage');
break;
case 7:
alert('User is underage');
break;
case 8:
alert('User is underage');
break;
case 9:
alert('User is underage');
break;
default:
alert('Form is submitted');
}
}
Thank you,
Rishi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2017 11:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2017 11:04 PM
Hi Rishi,
You can use simple "if else" conditions if you have few age ranges are defined,
Eg:
var tst = g_form.getValue('u_age');
tst = tst.parseInt();
if((tst>10)&&(tst<19)){
alert('user is underage');
return false;
}
else if(tst>=19){
//your code
}
Regards,
Saikiran Guduri.
(P.S: Please mark the reply as "Helpful"/"Correct" accordingly.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2017 11:34 PM
thanks you SaiKiran.
It is working for me.
Rishi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2017 11:48 PM
Hi Rishi,
Please mark the reply as "Correct Answer " in case it helped. So that this thread will be removed from unanswered list.
Regards,
Saikiran Guduri.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 12:03 PM
Hi Rishi,
You have marked your reply as "Correct".
If my answer/reply is helping you, please mark my reply as "Correct".
Regards,
Saikiran Guduri