Check value between 2 numbers using catalog client script

rishi4200
Giga Expert

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

1 ACCEPTED SOLUTION

thanks you SaiKiran.


It is working for me.




Rishi


View solution in original post

4 REPLIES 4

Saikiran Gudur1
Mega Guru

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.)


thanks you SaiKiran.


It is working for me.




Rishi


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.


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