Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

javascript validation error - HALP!1 :(

  • 09-12-2008 02:58PM
    #1
    Closed Accounts Posts: 8,866 ✭✭✭


    Can someone please suggest to me why this validation works in Google Chrome and IE6 and doesn't work in Firefox?!

    [php]
    function checkData(frm)
    {
    if(!CheckEmpty(pd.name.value,"Name"))
    {
    pd.name.focus();
    return false;
    }
    if(!CheckNumber(pd.phone.value,"Phone Number"))
    {
    pd.phone.value='';
    pd.phone.focus();
    return false;
    }
    if(!CheckEmpty(frm.email.value,"Email Address"))
    {
    frm.email.focus();
    return false;
    }
    if(!CheckEmailAddr(pd.email.value,"Email Address"))
    {
    alert("Invalid Email Address");
    pd.email.value='';
    pd.email.focus();
    return false;
    }
    if(isNaN(document.pd.frmRetirementAge.value))
    {
    alert("Retirement Age should be Numeric");
    pd.frmRetirementAge.value='';
    pd.frmRetirementAge.focus();
    return false;
    }
    if(isNaN(document.pd.frmNetGrowthRate.value))
    {
    alert("Net growth rate should be Numeric");
    pd.frmNetGrowthRate.value='';
    pd.frmNetGrowthRate.focus();
    return false;
    }
    if(isNaN(document.pd.frmEscalation.value))
    {
    alert("Premium Escalation should be Numeric");
    pd.frmEscalation.value='';
    pd.frmEscalation.focus();
    return false;
    }
    if(isNaN(document.pd.frmInflation.value))
    {
    alert("Inflation should be Numeric");
    pd.frmInflation.value='';
    pd.frmInflation.focus();
    return false;
    }
    if(isNaN(document.pd.frmAge.value))
    {
    alert("Current Age should be Numeric");
    pd.frmAge.value='';
    pd.frmAge.focus();
    return false;
    }
    if(isNaN(document.pd.frmValueOfExisitingFunds.value))
    {
    alert("Value Of Existing Funds should be Numeric");
    pd.frmValueOfExisitingFunds.value='';
    pd.frmValueOfExisitingFunds.focus();
    return false;
    }
    if(isNaN(document.pd.frmPensionRequiredInTodaysTerms.value))
    {
    alert("Pension Required should be Numeric");
    pd.frmPensionRequiredInTodaysTerms.value='';
    pd.frmPensionRequiredInTodaysTerms.focus();
    return false;
    }
    if(isNaN(document.pd.frmContribution.value))
    {
    alert("Monthly Contribution should be Numeric");
    pd.frmContribution.value='';
    pd.frmContribution.focus();
    return false;
    }
    testForm()
    }
    [/php]


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Download the web developer toolbar for firefox and it will show you any JavaScript errors.

    Can you put up the form you're validating?
    Where are CheckEmpty, CheckEmailAddr and CheckNumber defined?
    Are you getting script errors?


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    eoin wrote: »
    Download the web developer toolbar for firefox and it will show you any JavaScript errors.

    Can you put up the form you're validating?
    Where are CheckEmpty, CheckEmailAddr and CheckNumber defined?
    Are you getting script errors?
    apparently "pd is not defined". this is the form name. in what way should this be defined exactly? i'm not a javascript head unfortunately, it's code on a site i was upgrading and now they think this problem was me :(


  • Closed Accounts Posts: 106 ✭✭AvrilLavigne


    var pd = document.getElementsByName("pd");


  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    As avril says or just using document.pd should work


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    var pd = document.getElementsByName("pd");
    name didn't work, so i change it to getElementById, and it's working now. just thought i'd ask is there anything wrong with what i've done there? thanks for the help!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Or just use document.getElementById("form_field_id").value

    Just make sure your form fields have an id as well as a name attribute.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I can recommend firebug for firefox. Its a brilliant web dev tool. Allowing examination of the DOM, CSS, HTML and JavaScript. You can even set breakpoints and step through your JavaScript.

    In fact, I may even consider a firebug tutorial series once I get my current hosting problems sorted out.


Advertisement