How to popup message or alert on Servicenow portal for Quantity drop-down field ?

Virendra K
Kilo Sage

Hi All,

I want to popup a message /alert if user is selecting more than 8 quantity in the below drop down field(snap 1). 

Do I need to do the coding in HTML template or Client script or Server script ?  I have find coding part for this field in HTML template (snap2)

Please let me know how I can popup message and stop user to select more than 8 number /qty ? 

Snap1:

find_real_file.png

 

Snap2:

find_real_file.png

 

Thank you.

Regards,

Virendra

 

 

12 REPLIES 12

Hi,

seems it is unable to find html element with that class

try checking on portal if any html element with that class is present or not

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you!  This worked once I changed the highlighted line. 

function onSubmit() {


if(window == null){
     
     var z = this.document.getElementsByClassName("select2-chosen");

     //if(z[1].innerHTML > 8 ){
     if(z[0].innerHTML > 8 ){
          alert('Please select value less than 8');
          return false;
     }
}
else{

     var quantity = $j('#quantity').val();
     if(quantity > 8){
          alert('Please select value less than 8');
          return false;
     }
}
}

You are welcome

Do remember to mark appropriate responses as helpful

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader