...

View Full Version : Want a regular expression and its usage



asnmurthy
04-24-2004, 02:23 AM
Hi,
can anyone give me the code for the following requirement:

I have one text area. User enters anyhting including a newline character.
using javascript regexp, I should allow only alphanumeric string including newline(\n) character in that. otherwise give an alert message.
Help is highly appreciated.

Thanks & Regards,
Murthy
annavajjhula@yahoo.com

Philip M
04-24-2004, 09:04 AM
function checkit (thetextinputbytheuser) {
if (/[^a-zA-Z0-9\n]/.test (thetextinputbytheuser)) {
alert ("You may only enter alphanumeric characters");
textboxname.focus();
return false;
}
}

Be aware that this will disallow punctuation such as , ? or !

Was this a homework assignment?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum