473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

If any illegal char exist do.. script help

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(){
  2.  
  3.  
  4.  
  5.        if ( i don't know what ){
  6.        alert('There are illegals!');
  7.  
  8.        document.MyJavaScriptForm.MyField.focus();
  9.     return false;
  10.     }
  11.  
  12.  
  13.  
  14. document.MyJavaScriptForm.submit();
  15.  
  16. }

Can you help me please? Thank you!
Jul 2 '08 #1
1 1306
acoder
16,027 Expert Mod 8TB
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:
http://developer.mozilla.org/en/docs...ar_Expressions
http://www.regular-expressions.info/javascript.html
http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Jul 2 '08 #2

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

Similar topics

14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
2
by: Lambda | last post by:
The code is simple: // Token.h #ifndef TOKEN_H #define TOKEN_H #include <vector> #include <string> class Token
1
by: JRough | last post by:
We got a dedicated hosted server to replace a shared hosted server. I reloaded the database tables and data and scripts. I noticed that most of the tables had latin1_swedish_collation but some...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.