|
-
Nov 25th, 2002, 07:29 PM
#1
Thread Starter
Hyperactive Member
Invalid Characters.
I want to write a Javascript function so that the user is barred from entering invalid characters like"!@#$%^&*()_+" in a sensitive field like User Name.
Please Help.
-
Nov 25th, 2002, 08:06 PM
#2
Good Ol' Platypus
You can do this during validation of a form. Just see if any of them are in the string and if it is, cancel the submission of the form.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 26th, 2002, 12:27 AM
#3
Thread Starter
Hyperactive Member
I haven't done much of javascript. Can i get the syntaxes pls.
-
Nov 26th, 2002, 04:28 AM
#4
Code:
//param val is string to check ie username
function isAlphaNumeric(val){
var str = new String(val);
return (str.search(/\W/)=="-1")?true:false;
}
Add an onClick event to the login button and call the function
if it's true and other validation ok then submit the form
-
Nov 26th, 2002, 04:44 AM
#5
Frenzied Member
Add it to the onsubmit of the form instead, it's the better place to put it (unless you have two submit buttons and you don't need the validation for one)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|