By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,998 Members | 456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,998 IT Pros & Developers. It's quick & easy.

If any illegal char exist do.. script help

P: 1
Hello everyone! My name is Veselin and i'm php and mysql coder. But now i have big problems with one javascript that i want to create (maybe because i don't understand nothing from javascript :)). I want to create validate form that search for illegal chars. "." "/" "_" "\" ","

My form name: MyJavaScriptForm
Field that i want to check: MyField

I'm made this..

Expand|Select|Wrap|Line Numbers
  1. function check(){
  5.        if ( i don't know what ){
  6.        alert('There are illegals!');
  8.        document.MyJavaScriptForm.MyField.focus();
  9.     return false;
  10.     }
  14. document.MyJavaScriptForm.submit();
  16. }

Can you help me please? Thank you!
Jul 2 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
Maybe you could just check for valid characters instead, but that really depends. If you only want alphanumeric characters, it's better to check against that instead of checking for every illegal character. However, if you want to allow any character except those that you've listed, then it makes more sense to check for those instead.

Now, how do we validate? The first thing to do is to get the input field value. Then you can use regular expressions to check the value. See these links:
Jul 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.