• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

special charecters should not be enter in email address

 
Chennarao Marvatu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,
The thing it should not allow the special characters in the email address.

When u try to enter the special character it user should feel that special character

Will not allow that is character should be vhown and remove..



I have done the total functionality but when I try to enter the spl char at the middle of the

It is removing the remaining all characters. If remove the comment at line # 32

It is giving functionality like when we type the special characters more than one

By pressing the shift button it is removing only first character..
Note :----- i am calling this function in onkeyup

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) > -1) || key == 13 ){
return ;
}
else {
var temp = textarea.value ;
for(i=0;i<temp.length;i++){
var tempkeychar = temp.charAt(i).toLowerCase();
if(! (allowedChars.indexOf(tempkeychar) > -1 )){
// alert("after charecter----"+notAllowedChars.indexOf(tempkeychar));
// for(j=0;j<tempkeychar.length;j++){
document.forms[0].email.value = temp.substr(0,i)//+temp.substr(i+1,temp.length);
//}
//alert("before charecter----"+temp.substr(0,i));
return;
}
}
}
}
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally would not limit the user text input when the user is typing. I would do it after they are done with the form submission or onblur/onchange of the text field.

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic