Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

CRM JavaScripts Form Validations

CRM JavaScripts Form Validations

Here is some ready made JS function that we can use in our web pages or form.
cropped-creative_wallpaper_modern_man_034276_.jpg
Validate a Mandatory Field

[code language=”css”]
function CheckRequiredFields() {
if (document.getElementById("txtMobile").value== "")
{
alert("Value is Required !");
return false;
}
}
[/code]

Allow Only Numeric Values

[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]

E-mail Address Validation
[code language=”css”]
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]

Alphabets Only Validation
[code language=”css”]
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]

Alpha-Numeric Only Validation
[code language=”css”]
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]

Validate India Mobile Number (10 Digit)
[code language=”css”]
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]