here some simple code to validate the field of the form in crm
main phone
var e = /^(\+91[\-\s]?)?[123456789]\d{9}$/;
if(crmForm.all.telephone1.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.telephone1.value = ''; //to make field blank.
crmForm.all.telephone1.SetFocus(); //to set the focus on particular field.
event.returnValue=false;
}
fax
var e = /^[+]\d{12}$/;
if(crmForm.all.fax.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.fax.value = '';
crmForm.all.fax.SetFocus();
event.returnValue=false;
}
city
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.address1_city.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.address1_city.value = '';
crmForm.all.address1_city.SetFocus();
event.returnValue=false;
}
zip postal code
var e =/^\d{6}$/;
if(crmForm.all.address1_postalcode.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.address1_postalcode.value = '';
crmForm.all.address1_postalcode.SetFocus();
event.returnValue=false;}
first name
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.firstname.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.firstname.value = '';
crmForm.all.firstname.SetFocus();
event.returnValue=false;
}
state/province
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.address1_stateorprovince.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.address1_stateorprovince.value = '';
crmForm.all.address1_stateorprovince.SetFocus();
event.returnValue=false;
}
main phone
var e = /^(\+91[\-\s]?)?[123456789]\d{9}$/;
if(crmForm.all.telephone1.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.telephone1.value = ''; //to make field blank.
crmForm.all.telephone1.SetFocus(); //to set the focus on particular field.
event.returnValue=false;
}
fax
var e = /^[+]\d{12}$/;
if(crmForm.all.fax.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.fax.value = '';
crmForm.all.fax.SetFocus();
event.returnValue=false;
}
city
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.address1_city.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.address1_city.value = '';
crmForm.all.address1_city.SetFocus();
event.returnValue=false;
}
zip postal code
var e =/^\d{6}$/;
if(crmForm.all.address1_postalcode.value.search(e) == -1)
{alert('number should be proper');
crmForm.all.address1_postalcode.value = '';
crmForm.all.address1_postalcode.SetFocus();
event.returnValue=false;}
first name
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.firstname.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.firstname.value = '';
crmForm.all.firstname.SetFocus();
event.returnValue=false;
}
state/province
var e = /^[a-zA-Z\s]+$/;
if (crmForm.all.address1_stateorprovince.value.search(e)==-1)
{
alert("Only alphbets or space allowed");
crmForm.all.address1_stateorprovince.value = '';
crmForm.all.address1_stateorprovince.SetFocus();
event.returnValue=false;
}