Cybercrux

Everything is achievable through technology

Validation

//numeric validation include + –
function isNumberKey(evt)
{

var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 43 && charCode != 45 )
{

alert(‘Please enter a numeric value.’);
return false;

}
return true;

}

 

function EmailVali(EMail) {
if (EMail.value != “”) {
var filter1 = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
if (filter1.test(EMail.value)) { return (true) }
alert(“‘” + EMail.value + “‘ Invalid E-mail Address! Please re-enter.”);
EMail.focus();
return false;
}
}

Advertisements

2 thoughts on “Validation

  1. Date Validation

    function isValidDate(subject) {
    if (subject.value.match(/^((((0[13578]|[13578])|1[02])[\- \/.]((0[1-9]|[1-9])|[12]\d|3[01])[\- \/.]((19|[2-9]\d)\d{2}))|((0[13456789]|[13456789])|1[012])[\- \/.](((0[1-9]|[1-9])|[12]\d|30)[\- \/.]((19|[2-9]\d)\d{2}))|(02|2)[\- \/.](((0[1-9]|[1-9])|1\d|2[0-8])[\- \/.]((19|[2-9]\d)\d{2}))|((02|2)[\- \/.]29[\- \/.]((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/))
    {
    return true;
    }
    else {
    if (subject.value == “”) { return false; }
    alert(“Please enter a valid date (mm/dd/yyyy)”);
    subject.value = “”;
    return false;
    }
    }

  2. Alpha numeric only

    $(document).ready(function () {

    $(‘input’).keyup(function() {
    var $th = $(this);
    $th.val( $th.val().replace(/[^a-zA-Z0-9]/g, function(str) { alert(‘You typed ” ‘ + str + ‘ “.\n\nPlease use only letters and numbers.’); return ”; } ) );
    });
    });

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s