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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pattern matching, regular expressions

Status
Not open for further replies.

johne417

Programmer
Sep 18, 2001
23
US
This is really odd...

<script language="javascript">

function checkCharacter(e) {

// \w+ any/repeating word character

validString=/\w+/;

if (!validString.test(e)) {
alert('false');
}
else {
alert('true');
}
}
</script>

<form action="" onSubmit="checkCharacter(this.testChar.value);" method="post">
<input type="text" name="testChar">
<input name="submit" type="submit" value="submit">
</form>



So this should return false for any characters not in the \w, which means all non alpha-numeric characters. Normal strings work fine. Except when I put in any string with a _ (underscore) character, it returns false. \w shouldn't do that, right?
 
Ach, stupid error on my part, figgered it out. Disregard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top