aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
 
wood burning stoves
 
subject: handling special charecters in email field