Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format/Custom Keystroke Help

Status
Not open for further replies.

okiiyama

IS-IT--Management
Jan 3, 2003
269
0
0
US
I would like to make sure the user doesn't type special characters into a certain field.

I found this:
Code:
if(!event.change.match(/\w+/g)){
	app.alert("Enter Letters or Numbers only.");
	event.rc = false;
}
but that messes up the whole page. Is there something similar I can use?
 
It may be easier to only permit specific characters then to exclude all special ones - I have a script which does exactly this. It is designed to stop special characters from being entered into a field who's value is used for a filename.

Code:
function FN_ks()
 {
FN_RegExp = /[A-Z a-z 0-9 _ . -]{0,60}/;
var value = AFMergeChange(event);
if(!value) return;
if (!AFExactMatch(FN_RegExp, value)) event.rc = false;
}
if (!event.willCommit) FN_ks();

This code specifies the exact range of characters to allow, and also restricts the number of characters allowed to a maximum of 60 (to prevent over-running 256 chracters in path). I initially had set out to do exactly what you are attempting, and received some help via this forum to get me to the script above, so I'm just passing on the knowledge.

Rule Britannia, Britannia Waives the Rules
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top