Skip to main content
I have a button that executes javascript.  I want it to check a field to see if it contains "pend" (I'm looking for pending, pending3, 3pending, etc.).  The code below finds "pend" and "PEND", but if you throw in other characters it doesn't work.  Any ideas?

 

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}

 

{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")}

 

if ( {!ISBLANK( SVMXC__Service_Group__c.QADCode__c )} ){

 

alert('This team has no customer code, so we can not ship to them');

 

}

 

else if ({!CONTAINS("PEND", UPPER (SVMXC__Service_Group__c.QADCode__c))} ) {

 

alert('pend error');

 

}

 

else{

 

document.location.href="/apex/SVMX_Create_SalesOrder_ST?id={!SVMXC__Service_Group__c.Id}";

 

}
3 个回答
  1. 2013年4月17日 16:36
    Use this:

     

    var pendTest = '{!SVMXC__Service_Group__c.QADCode__c}';

     

    if(pendTest.indexOf("pend") !== -1){

     

        alert("pend found");

     

    }else{

     

        alert("pend not found")

     

    }
0/9000