Difference between revisions of "Making Contact Standard Fields Mandatory"

From SmartWiki
Jump to: navigation, search
m
Line 2: Line 2:
  
 
<pre>
 
<pre>
function additionalCheckingOnSubmit(){
+
function savefunc(frm){
    var frm=document.frmuser;
+
  var element=frm.uaddress;
    var element=frm.uaddress;
+
  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;
    element=frm.phone;
+
  if(element&&element.value.length==0){
    if(element&&element.value.length==0){
+
      alert("Phone is empty!");
        alert("Phone is empty!");
+
      return false;
        return false;
+
  }
    }
+
  element=frm.ucity;
    element=frm.ucity;
+
  if(element&&element.value.length==0){
    if(element&&element.value.length==0){
+
      alert("City is empty!");
        alert("City is empty!");
+
      return false;
        return false;
+
  }
    }
+
  element=frm.ucountry;
    element=frm.ucountry;
+
  if(element&&(element.value.length==0||element.value=="0")){
    if(element&&(element.value.length==0||element.value=="0")){
+
      alert("Country is empty!");
        alert("Country is empty!");
+
      return false;
        return false;
+
  }
    }
+
  element=frm.email;
    element=frm.email;
+
  if(element&&element.value.length==0){
    if(element&&element.value.length==0){
+
      alert("Email is empty!");
        alert("Email is empty!");
+
      return false;
        return false;
+
  }
    }
+
  return true;
    return true;
 
 
}
 
}
  
function savefunc(){return additionalCheckingOnSubmit();}
+
 
 
</pre>
 
</pre>
  
 +
 +
==See Also==
 +
* [[Making company standard fields mandatory]]
 +
* [[Making Company Mandatory for Contact Records]]
 
   
 
   
 
[[Category: Custom Fields]][[Category:JavaScript]]
 
[[Category: Custom Fields]][[Category:JavaScript]]

Revision as of 16:50, 5 May 2011

To make contact 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 contacts, you'll want to put the custom field in via Global Settings > User & Contact Settings > Contact Custom Fields

function savefunc(frm){
   var element=frm.uaddress;
   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.ucity;
   if(element&&element.value.length==0){
      alert("City is empty!");
      return false;
   }
   element=frm.ucountry;
   if(element&&(element.value.length==0||element.value=="0")){
      alert("Country is empty!");
      return false;
   }
   element=frm.email;
   if(element&&element.value.length==0){
      alert("Email is empty!");
      return false;
   }
   return true;
}



See Also