[Javascript] RegExp question
Christopher Basken
chriz at basken.com
Thu Dec 13 16:31:32 CST 2001
Hi,
I've got a page with a bunch of form elements on it. A bunch of elements
are named "course_01_02" or "course_12_01" and so on. I want to loop
through them and yank out the values of these elements, but since I also
need to know the digits, I need to match the numbers (not just the beginning
"course").
I've got this function:
function FormValidation(theForm) {
for (var i = 0; i < theForm.length; i++) {
var e = theForm.elements[i].name;
var pattern = new RegExp("course_(\d+)_\d+","ig");
alert(e.match(pattern)); // test
}
}
But it keeps coming up Null. According to the documentation at
developer.netscape.com, this should work.
Any thoughts?
Thanks!
Chris
More information about the Javascript
mailing list