marain
02-12-2013, 10:56 PM
I am looking at a script that has this code:
if ( form.yourName.value.length == 0 ) {
alert( "Please provide your name." );
form.yourName.focus();
return false;
Then, later on, it has this code:
var findSpace = /^(.+) (.+)$/;
var matchFlag = form.yourName.value.match( findSpace );
if ( matchFlag == null ) {
alert( "Please provide both a first and last name, and resubmit." );
form.yourName.focus();
return false;
}
My impression is that the first test is superfluous because the second test automatically encompasses the first. I would appreciate someone telling me whether I am missing something.
Thanks, as always.
A.
if ( form.yourName.value.length == 0 ) {
alert( "Please provide your name." );
form.yourName.focus();
return false;
Then, later on, it has this code:
var findSpace = /^(.+) (.+)$/;
var matchFlag = form.yourName.value.match( findSpace );
if ( matchFlag == null ) {
alert( "Please provide both a first and last name, and resubmit." );
form.yourName.focus();
return false;
}
My impression is that the first test is superfluous because the second test automatically encompasses the first. I would appreciate someone telling me whether I am missing something.
Thanks, as always.
A.