how to include " in my validation script

B

Bartosz Wegrzyn

I wrote this function to validate the name.


//test name for illegal characters
var illegal = "0123456789!@#$%^&*()-=_+[]\{}|;':,./?><";
for (var i=0;i<strng.length;i++) {
temp = strng.substring(i,i+1);

if (illegal.indexOf(temp) != -1 && strng != "")

{
error = "The name contains illegal characters.\n";
}

How can I include " character in my 'illegal' string.
Are there any other ways to tell string 'illegal' to include only letters.

I am not familiar with this.
If you know any links plesase give it to me.

Thanks
 
V

VK

function validate (thisString) {
var re = /[^A-Za-z]/g; // creating a regular expression
if (re.test(thisString)) {
error = "The name contains illegal characters.";
}
else {
// everything's fine
}
}
 
B

Bartosz Wegrzyn

thanks

I found this
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/regexp.html#1010922


VK said:
function validate (thisString) {
var re = /[^A-Za-z]/g; // creating a regular expression
if (re.test(thisString)) {
error = "The name contains illegal characters.";
}
else {
// everything's fine
}
}



Bartosz Wegrzyn said:
I wrote this function to validate the name.


//test name for illegal characters
var illegal = "0123456789!@#$%^&*()-=_+[]\{}|;':,./?><";
for (var i=0;i<strng.length;i++) {
temp = strng.substring(i,i+1);

if (illegal.indexOf(temp) != -1 && strng != "")

{
error = "The name contains illegal characters.\n";
}

How can I include " character in my 'illegal' string.
Are there any other ways to tell string 'illegal' to include only letters.

I am not familiar with this.
If you know any links plesase give it to me.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,090
Messages
2,570,603
Members
47,223
Latest member
smithjens316

Latest Threads

Top