//mobile number field
function permanentnumber() {
    var mob = Xrm.Page.getAttribute( "Filedname").getValue();
    var length = mob.length;
    if (length < 10 || length > 10) {
        alert( "Please Enter 10 Digit Number:" );
        Xrm.Page.getAttribute( "Filedname").setValue(null );
        return true;
    }
    if (mob > 31 && (mob < 48 || mob > 57)) { }
    else {
        alert( "Please Enter 10 Digit Number:" );
        return true;
    }
}
//--------------------------------------------------------------------------------------------------------------------------------------------
//phone number field
function phonenumber() {

    var phonenumber = Xrm.Page.getAttribute( "Filedname").getValue();
    if (phonenumber != null) {
        var length = phonenumber.length;
        if (length < 8 || length > 12) {
            alert( "Please Enter a Valid Digit Number:" );
            Xrm.Page.getAttribute( "Filedname").setValue(null );
            return true;
        }
        if (phonenumber > 31 && (phonenumber < 48 || phonenumber > 57)) { }
        else {
            alert( "Please Enter a Valid Digit Number:" );
            return true;
        }
    }
}
//--------------------------------------------------------------------------------------------------------------------------------------------
//zipcode
function zipcode() {
    var zipcode = Xrm.Page.getAttribute( "Filedname").getValue();
    var length = zipcode.length
    if (length < 6)
        alert( "Please Enter Valid Zipcode:");

    if (zipcode > 31 && (zipcode < 48 || zipcode > 57)) { return false; }
    else {
        alert( "Please Enter Valid Zipcode:");
        return true;
    }
}



SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012