View Full Version : Want a regular expression and its usage

04-24-2004, 01:23 AM
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,

Philip M
04-24-2004, 08:04 AM
function checkit (thetextinputbytheuser) {
if (/[^a-zA-Z0-9\n]/.test (thetextinputbytheuser)) {
alert ("You may only enter alphanumeric characters");
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