CRM JavaScripts Form Validations
[code language=”css”]
function CheckRequiredFields() {
if (document.getElementById("txtMobile").value== "")
{
alert("Value is Required !");
return false;
}
}
[/code]
[code language=”css”]
function IsNumericKey(e)
{
var inputvalue = window.event.keyCode;
if (inputvalue > 31 && (inputvalue < 48 || inputvalue > 57))
{
alert("Oops !!! I Accept only Numeric values.");
return false;
}
return true;
}
[/code]
function ValidateEmail() {
var x = document.getElementById("txtEmail").value;
var atposition = x.indexOf("@");
var dotposition = x.lastIndexOf(".");
if (atposition < 1 || dotposition < atposition + 2 || dotposition + 2 >= x.length) {
alert("Not a valid e-mail address");
return false;
}
}
[/code]
function ValidateName() {
var letters = /^[A-Za-z]+$/;
if (document.getElementById("txtFName").value.match(letters))
{
return true;
}
else {
alert(‘Oops !!! First Name must have alphabet characters only’);
document.getElementById("txtFName").focus();
return false;
}
}
[/code]
function ValidateAlphaNumeric() {
var pattern = /^[0-9a-zA-Z]+$/;
if (document.getElementById("txtAddress").value.match(pattern))
{
return true;
}
else {
alert(‘Oops !!! Address must have alphanumeric characters only’);
document.getElementById("txtAddress").focus();
return false;
}
}
[/code]
function ValidateIndiaMobileNo() {
var pattern = /^\d{10}$/;
if (document.getElementById("txtIndiaMob").value.match(pattern))
{
return true;
}
else {
alert(‘Oops !!! Not a Valid Indian Mobile Number’);
document.getElementById("txtIndiaMob").focus();
return false;
}
}
[/code]