web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

How to restict users from entering special characters in Microsoft Dynamics CRM 4.0

a33ik Profile Picture a33ik 84,331 Most Valuable Professional
Solution is very simple - just add following script to OnLoad event handler of form:

function SwitchOnCheck(ElementId)
{
var element = document.getElementById(ElementId);
if (element != null)
element.attachEvent("onkeyup", function()
{
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
var strPass = element.value;
if (strPass == null)
return;
var strLength = strPass.length;
var lchar = element.value.charAt(strLength - 1);
while(lchar.search(mikExp) != -1)
{
strPass = strPass.substring(0, strLength - 1);
if (strPass.length == 0)
break;
strLength = strPass.length;
lchar = strPass.charAt(strLength - 1);
}

element.value = strPass;
});
}

SwitchOnCheck('firstname');
SwitchOnCheck('lastname');

This was originally posted here.

Comments

*This post is locked for comments