This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes handling special charecters in email field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "handling special charecters in email field" Watch "handling special charecters in email field" New topic
Author

handling special charecters in email field

Chennarao Marvatu
Ranch Hand

Joined: Aug 09, 2004
Posts: 32
Hello Friends how are you..Hope you all fine.
Here my question is regarding not allowing the special charecters
in the email.I have taken the allowed charecters and not allowed charecters.
its working fine but i have to take only allowed charecters and other than
this charecters should not be allowed.So please help me out how to solve this by removing the notallowed charecters

function CheckValidity(textarea)
{
//alert("key--------"+window.event.keyCode);
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (event)
{
key = event.which;
}
else
return true;

keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
var allowedChars = "abcdefghijklmnopqrstuvwxyz1234567890@,_.-";
var notAllowedChars = "~`!#$%^&*()+=|\\\"\/';:?";

if((allowedChars.indexOf(keychar) greaterthan -1) || key == 13 ){

return ;
}
else {
var temp = textarea.value ;
for(i=0;i lessthan temp.length;i++){
var tempkeychar = temp.charAt(i);
if(notAllowedChars.indexOf(tempkeychar) greaterthan -1){
// alert("after charecter----"+notAllowedChars.indexOf(tempkeychar));
document.forms[0].email.value = temp.substr(0,i)+temp.substr(i+1,temp.length);
//alert("before charecter----"+temp.substr(0,i));
return;
}
}
}
}


mchrao
 
GeeCON Prague 2014
 
subject: handling special charecters in email field