Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

javascript validation error - HALP!1 :(

  • 09-12-2008 1: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,263 ✭✭✭✭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,263 ✭✭✭✭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