SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem adding variables to a function in a form

    Hi, firstly I apologise if the title of this thread isn't quite accurate. I'm sure you've all heard it before but I am a complete newbie to Javascript so again: apologies if this is boring and tiresome to even read, let alone help with!

    I have been asked to make some changes to a form that uses Javascript for the form validation. There is a 'function' that contains the variables of the various form fields and then further code to raise 'alerts' if one of the fields on the form hasn't been filled in. My problem is that for some reason I am unable to add an extra variable to this code after the field of 'County' (this will hopefully make sense when you see the code / link...) and I am stumped as to why. I am able to add variables for all of the other required fields except for 'Postcode' after 'County'. This is the case for both forms. The link is here: http://samdelara.co.uk/previews/banq...ation-form.htm and the code I am trying edit is below. The issues seems to be when I add && isPostcode() to this chunk of code:-

    Code JavaScript:
    function checkAvailibility()
    {
    // re-calculate...
    calculate ();
    if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isTel() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) {
      document.ordersummary.emailQuote.value = "No";
      setValue();
     return true;
     }
     else
     {
     return false;
     }
    }

    /************* FULL CODE BELOW ******************/

    Code JavaScript:
    function checkAvailibility()
    {
    // re-calculate...
    calculate ();
    if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isTel() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) {
      document.ordersummary.emailQuote.value = "No";
      setValue();
     return true;
     }
     else
     {
     return false;
     }
    }
     
     
    function isName() { if (document.ordersummary.Name.value=="") { alert ("\n Please Enter Your Name")
    document.ordersummary.Name.focus(); return false; } return true; }
    function isAddress1() { if (document.ordersummary.Address1.value=="") { alert ("\n Please Enter Your Address")
    document.ordersummary.Address1.focus(); return false; } return true; }
    function isTown() { if (document.ordersummary.Town.value=="") { alert ("\n Please Enter Your Town")
    document.ordersummary.Town.focus(); return false; } return true; }
    function isCounty() { if (document.ordersummary.County.value=="") { alert ("\n Please Enter Your County")
    document.ordersummary.County.focus(); return false; } return true; }
    function isTel() { if (document.ordersummary.Tel.value=="") { alert ("\n Please Enter Your Telephone Number")
    document.ordersummary.Tel.focus(); return false; } return true; }
    function isPostcode() { if (document.ordersummary.Postcode.value=="") { alert ("\n Please Enter Your Postcode")
    document.ordersummary.Postcode.focus(); return false; } return true; }
    function isYourEmail() { if (document.ordersummary.YourEmail.value=="") { alert ("\n Please Enter Your Email")
    document.ordersummary.YourEmail.focus(); return false; } return true; }
    function isFuncDate() { if (document.ordersummary.FuncDate.value=="") { alert ("\n Please Enter Your Function Date")
    document.ordersummary.FuncDate.focus(); return false; } return true; }
    function isemailonly() { if (document.ordersummary.emailonly.value=="") { alert ("\n Please Enter Your Email Address")
    document.ordersummary.emailonly.focus(); return false; } return true; }

    Any help would be massivley appreciated!!
    Attached Images Attached Images
    Last edited by Mittineague; Jun 17, 2011 at 19:54. Reason: reformatting bbcode tags


Bookmarks

Posting Permissions

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