Email Validation Javascript
Dynamics CRM has alreaady an inbuilt email address validation mechanism but if you have any custom entity or to do a robust email validation on out-of-the-box fields then you can use the below script.
function validateEmail() { //replace the attribute used to suit your field var email = Xrm.Page.getAttribute("emailaddress1").getValue(); if(email != "") { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if(re.test(email) == false) { alert("The email address is invalid"); Xrm.Page.getAttribute("emailaddress1").setValue(""); } } }
You can check the video how to add this validation in Dynamics CRM application here.