Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script not working

    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;

    }
    }
    Last edited by WA; 02-03-2007 at 08:29 PM.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,088
    Thanks
    2
    Thanked 23 Times in 23 Posts
    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.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I see some weird lines:

    Code:
    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:
    Code:
    }else if(Number(tfld)<1904){
    .......
    }else if(Number(tfld)>2007){
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •