Menu Close

EMAIL FIELD VALIDATION MS CRM

Hi 

I had a scenario which everyone aware of the email field validation
function EmailValidation_Primaryemailaddress() {
    var primaryemailaddress = Xrm.Page.getAttribute(“new_primaryemailaddress”).getValue();
    if (primaryemailaddress != null) {
        var reg = /^w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*$/
        if (!reg.test(primaryemailaddress)) {
            Xrm.Page.getControl(“new_primaryemailaddress”).setNotification(“please enter valid email address”);
            Xrm.Page.getControl(“new_primaryemailaddress”).setFocus();
        }
    } else {
        Xrm.Page.getControl(“new_primaryemailaddress”).clearNotification();
    }
}
function EmailValidation_Secondaryemailaddress() {
    var secondaryemailaddress = Xrm.Page.getAttribute(“new_secondaryemailaddress”).getValue();
    if (secondaryemailaddress!=null) {
        var reg = /^w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*$/
        if (!reg.test(secondaryemailaddress)) {
            Xrm.Page.getControl(“new_secondaryemailaddress”).setNotification(“please enter valid email address”);
            Xrm.Page.getControl(“new_secondaryemailaddress”).setFocus();
        }
    } else {
        Xrm.Page.getControl(“new_secondaryemailaddress”).clearNotification();
    }
    
}
function EmailValidation_primarymedicalsecretarypaemailaddress() {
    var primarymedicalsecretarypaemailaddress = Xrm.Page.getAttribute(“new_primarymedicalsecretarypaemailaddress”).getValue();
    if (primarymedicalsecretarypaemailaddress!=null) {
        var reg = /^w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*$/
        if (!reg.test(primarymedicalsecretarypaemailaddress)) {
            Xrm.Page.getControl(“new_primarymedicalsecretarypaemailaddress”).setNotification(“please enter valid email address”);
            Xrm.Page.getControl(“new_primarymedicalsecretarypaemailaddress”).setFocus();
        }
    } else {
        Xrm.Page.getControl(“new_primarymedicalsecretarypaemailaddress”).clearNotification();
    }
   
}
I hope this helps 
Happy CRMing
Share this:
Posted in Blog

Related Posts