Difference between revisions of "Making Company Standard Fields Mandatory"

From SmartWiki
Jump to: navigation, search
 
Line 2: Line 2:
  
 
<pre>
 
<pre>
function additionalCheckingOnSubmit(){
+
function savefunc(frm){
    var frm=document.frmcompany;
+
  var element=frm.address;
    var element=frm.address;
+
  if(element&&element.value.length==0){
    if(element&&element.value.length==0){
+
      alert("Address is empty!");
        alert("Address is empty!");
+
      return false;
        return false;
+
  }element=frm.phone;
    }
+
  if(element&&element.value.length==0){
    element=frm.phone;
+
      alert("Phone is empty!");
    if(element&&element.value.length==0){
+
      return false;
        alert("Phone is empty!");
+
  }element=frm.city;
        return false;
+
  if(element&&element.value.length==0){
    }
+
      alert("City is empty!");
    element=frm.city;
+
      return false;
    if(element&&element.value.length==0){
+
  }element=frm.country;
        alert("City is empty!");
+
  if(element&&(element.value.length==0||element.value=="0")){
        return false;
+
      alert("Country is empty!");
    }
+
      return false;
    element=frm.country;
+
  }return true;
    if(element&&(element.value.length==0||element.value=="0")){
 
        alert("Country is empty!");
 
        return false;
 
    }
 
    return true;
 
 
}
 
}
  
function savefunc(){return additionalCheckingOnSubmit();}
 
 
</pre>
 
</pre>
  
 
[[Category: Custom Fields]][[Category:JavaScript]]
 
[[Category: Custom Fields]][[Category:JavaScript]]

Revision as of 16:41, 5 May 2011

To make company standard fields mandatory, you must create a custom field of type Custom Field Type: Special – Browser Script and place it on the same entity that you'll be using it. For companies, you'll want to put the custom field in via Global Settings > Branch & Account Settings > Account Custom Fields

function savefunc(frm){
   var element=frm.address;
   if(element&&element.value.length==0){
      alert("Address is empty!");
      return false;
   }element=frm.phone;
   if(element&&element.value.length==0){
      alert("Phone is empty!");
      return false;
   }element=frm.city;
   if(element&&element.value.length==0){
      alert("City is empty!");
      return false;
   }element=frm.country;
   if(element&&(element.value.length==0||element.value=="0")){
      alert("Country is empty!");
      return false;
   }return true;
}