...

View Full Version : Script not working



farakhkhan
02-03-2007, 02:57 PM
http://www.xs4all.nl/~sbpoley/webmatters/formval.html

This code is not working with titled script. any help will be appreciated. thanks in advance

function validateEstyr (valfield, // element to be validated

infofield, // id of element to receive info/error msg

required) // true if required

{

var stat = commonCheck (valfield, infofield, required);

if (stat != proceed) return stat;



var tfld = trim(valfield.value); // value of field with whitespace trimmed off

var estyr = /^\+?[0-9]+[0-9]$/ ;

if (!estyr.test(tfld)) {

msg (infofield, "error", "ERROR: Only Digits Allowed");

setfocus(valfield);

return false;

}else if(estyr <1904){

msg (infofield, "error", "ERROR: Invalid Establishment Year");

setfocus(valfield);

return false;

}else if(estyr >2007){

msg (infofield, "error", "ERROR: Establishment Year cannot excceed the current year");

setfocus(valfield);

return false;

}
}

vinyl-junkie
02-03-2007, 11:22 PM
Saying "the code is not working" is not particularly informative. What exactly is it doing (or not doing)?

p.s. - Please use code tags to set apart code from text in your posts.

Kor
02-05-2007, 11:44 AM
I see some weird lines:



var estyr = /^\+?[0-9]+[0-9]$/ ;
.......
}else if(estyr <1904){
.......
}else if(estyr >2007){


your variable estyr was set as a regular expression object. You can not compare an RegExp object with a decimal number

I am not very sure what you want to, but I guess you want to compare the value of some form's element, probably:


}else if(Number(tfld)<1904){
.......
}else if(Number(tfld)>2007){



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum