@sh said the following on 12/20/2005 6:41 AM:[color=blue]
> Has anyone a function handy that I can apply to various textboxes within a
> form, each textbox will permit most characters but I want to ban certain
> characters from each textbox.
>
> Therefore I need a function that I can put into the <text area> tag of each
> box, something like...
>
> <text area onKeyPress="BanCharacters('a','<','>','b','u','i') ;">[/color]
<textarea onkeypress="banCharacters(this,'character list here');
name="myTextArea1">
Then banCharacters could check the keystrokes and compare against the
list. If its in the list, return false.
Might be better to have an array or simple object for each textarea
predefined so that you don't have to worry about syntax or arguments
list length.
Even simpler/better would be an array/object that had a list of all of
them. Something like this:
var myList = new Object();
myList['myTextArea1'] = ['a','<','>','b','u','i']
myList['myTextArea2'] = ['<','>','b','u','i']
and so on.
function banCharacters(textAreaRef){
//myList[textAreaRef.name] will give you a reference to the list.
//loop through that list and compare to the keypress.
//return false if it matches
}
There is more work to it than that, but the approach is there. Write
your best try at it and post it back here.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/