• Post Reply Bookmark Topic Watch Topic
  • New Topic

special characters not inlcude in textbox?

 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<input type="text" name="test" class="form-control input-sm" maxlength="20"/>

this is my textbox can i include in my tetxbox that it will no accept special characters?
cain i configure it there? like maxlength="20" w/c is character limit is set to 20,
not allowing special characters be configure like that , character="speical is not allowed" something like that?
thank you :)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chrstian,
Not in HTML. You can write JavaScript for it though. Either using the onKeyUp or onChange event handlers depending on whether you want to validate one character at a time or just when leaving the field.
 
Ben Allen
Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also remember anything you tell the client to validate is only a suggestion. They can send any input they want.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Allen wrote:Also remember anything you tell the client to validate is only a suggestion. They can send any input they want.

That's true. They can send more than 20 characters and ignore the max length for that matter.
 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
special characters are too many what i did in this was vice versa i only allowed all the characters that are required w/ is alphanumeric.

var textbox=document.getElementById("textboxid");
var valid=/^[a-zA-Z0-9]+$/;
if(textbox.value.match(valid)){
do the action
}
else{
print error message
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!