• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

handling special charecters in email field

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
}
}
}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic