Answered by:
E- mail validation in ms crm 4.0

Question
-
I am creating some customer aspx pages for MS CRM 4.0
I want to give email validation for a textbox control same as that found in CRM 4.0
Is the javascript code to perform email validation available.Please help.
Regards
RajiWednesday, May 27, 2009 11:23 AM
Answers
-
You can either use the same validation technique and pattern that ms is using e.g.
function OnCrmPageLoad()
{crmForm.<field that needs validation>.attachEvent( “onchange” , OnEmailValidate)
}
function OnEmailValidate()
{var emailRegex = /^[^@\s\"<>)(\[\]:;,]+@[^@\s\"<>)(\[\]:;,]+$/;
if (crmForm.<field that needs validation>.DataValue != null)
{
if (crmForm.<field that needs validation>.DataValue.match(emailRegex) == null){
alert(“invalid email…”);
}
}
}OnCrmPageLoad();
Or simply replace the field class name from ms-crm-Text to ms-crm-Email-Address e.g.
function OnCrmPageLoad()
{crmForm.<field that needs validation>.className = “ms-crm-Email-Address”;
}OnCrmPageLoad();
Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/- Proposed as answer by Nishant RanaMVP Tuesday, June 2, 2009 5:26 AM
- Marked as answer by DavidJennawayMVP, Moderator Monday, June 8, 2009 6:05 AM
Monday, June 1, 2009 8:28 AM
All replies
-
Hi Raji,
Try this :
http://www.4guysfromrolla.com/webtech/052899-1.shtml
Regards,
Chinmay
http://metrix.blogspot.com- Proposed as answer by Chinmay Patel Wednesday, May 27, 2009 11:49 AM
Wednesday, May 27, 2009 11:35 AM -
Hi Raji,
There are plenty. You could use regular expressions JavaScript validatr code.
Below is one example
<script language="javascript"> function checkEmail() { var email = document.getElementById(’emailaddress’); var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email.value)) { alert(’Please provide a valid email address’); email.focus return false; } } </script>
You could even have strict rules. See below for a stricter JavaScript example (EMAIL and PHONE both)
EMAIL = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/ PHONE = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/
Hope that helps!
Best Regards, Gagandeep Singh http://mscrmnovice.blogspot.com- Proposed as answer by Gagandeep.Singh Wednesday, May 27, 2009 11:42 AM
Wednesday, May 27, 2009 11:40 AM -
Are these exactly the same rules as found in MS C RM 4.0 application
Regards
RajiThursday, May 28, 2009 5:42 AM -
Hi,
If you need exactly the same javascript used in CRM 4.0, than you may need to search for it in .js files within the CRM server !
Regards,
Nishant Rana
http://nishantrana.wordpress.comThursday, May 28, 2009 6:15 AM -
Hi Raji,These are general rules for validating an email ID. You may look into .js files on the server to find Dynamics CRM rules.
Best Regards,
Gagandeep Singh
http://mscrmnovice.blogspot.comMonday, June 1, 2009 5:10 AM -
You can either use the same validation technique and pattern that ms is using e.g.
function OnCrmPageLoad()
{crmForm.<field that needs validation>.attachEvent( “onchange” , OnEmailValidate)
}
function OnEmailValidate()
{var emailRegex = /^[^@\s\"<>)(\[\]:;,]+@[^@\s\"<>)(\[\]:;,]+$/;
if (crmForm.<field that needs validation>.DataValue != null)
{
if (crmForm.<field that needs validation>.DataValue.match(emailRegex) == null){
alert(“invalid email…”);
}
}
}OnCrmPageLoad();
Or simply replace the field class name from ms-crm-Text to ms-crm-Email-Address e.g.
function OnCrmPageLoad()
{crmForm.<field that needs validation>.className = “ms-crm-Email-Address”;
}OnCrmPageLoad();
Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/- Proposed as answer by Nishant RanaMVP Tuesday, June 2, 2009 5:26 AM
- Marked as answer by DavidJennawayMVP, Moderator Monday, June 8, 2009 6:05 AM
Monday, June 1, 2009 8:28 AM -
Hi,
To find out the jscript used by CRM , check out this wonderful post
Investigating the generated script code of CRM forms
Regards,
Nishant Rana
http://nishantrana.wordpress.comTuesday, June 2, 2009 5:28 AM