M
maxwells
Dear Friends,
The following is part of my form validation script. It checks that the
user name entered is in Wiki name format.
function checkup(theform){
var form = document.forms[theform];
var okay = true;
var wikiName = form.name.value.match(/[A-Z][a-z0-9]*[0-9A-Z]/);
if (wikiName.length<3) {
alert(form.name.value + ' is not a WikiName - please use one word
with at least two capital letters');
okay = false;
}
return okay;
}
Normally, if the wikiName returns a match of more than three letters
then a successful match has been returned, so the name is in Wiki
format.
The thing is, even I do enter a valid Wiki name, such as "WikiName",
it is refused. So I put in a couple of debugging alert statements
before the if {} clause, to see what was going on:
alert (wikiName);
alert (wikiName.length);
The result was:
WikiN
1
How can this be? The string is correctly matched, and has 5
characters. So why would its length be reported as 1?
I tried this on Firefox and Explorer, same result both times.
Can anybody solve this mystery?
Thanks for your time,
Dalgetty
The following is part of my form validation script. It checks that the
user name entered is in Wiki name format.
function checkup(theform){
var form = document.forms[theform];
var okay = true;
var wikiName = form.name.value.match(/[A-Z][a-z0-9]*[0-9A-Z]/);
if (wikiName.length<3) {
alert(form.name.value + ' is not a WikiName - please use one word
with at least two capital letters');
okay = false;
}
return okay;
}
Normally, if the wikiName returns a match of more than three letters
then a successful match has been returned, so the name is in Wiki
format.
The thing is, even I do enter a valid Wiki name, such as "WikiName",
it is refused. So I put in a couple of debugging alert statements
before the if {} clause, to see what was going on:
alert (wikiName);
alert (wikiName.length);
The result was:
WikiN
1
How can this be? The string is correctly matched, and has 5
characters. So why would its length be reported as 1?
I tried this on Firefox and Explorer, same result both times.
Can anybody solve this mystery?
Thanks for your time,
Dalgetty