PDA

View Full Version : What does this script do?? CAN YOU FIGURE IT OUT?


bloodless_1999
01-08-2003, 08:46 PM
Can anyone tell me what the following code does? I know what it's SUPPOSED to do, but not what it actuall does. I've been staring at it for a LONG time, and can't get it.

var valid = new Object();
valid.Currency = /\u\d{6}$/;

var elArr = form1.elements;

for(var i = 0; i < elArr.length; i++) {

with(elArr[i]) {
var v = elArr[i].validator;
if(!v) continue;
var thePat = valid[v];
var gotIt = thePat.exec(value);
if(! gotIt){
alert("Please Fill out the EMPLOYEE NUMBER field correctly using the letter U and numbers. (Ie. U123456)");
elArr[i].select();
elArr[i].focus();
return false;
}
}
}



... later ...

<input name="EmplNum" validator="Currency" size="10">

TIA for any help!

arnyinc
01-08-2003, 09:10 PM
It looks like a small fragment of an unknown function and a text box with a validator parameter (never seen that before).

I'm bad at regular expressions, but I don't believe there is a \u. If you just want to match the letter u, I think it should be:

/u/\d{6}$/;