SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    933
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow countcode not defined?

    hi,

    i can't see the reason why the firefox "error console" is showing this message
    always --> "countcode not defined."

    ok here is the form codes. (contact.htm)
    Code:
    <div id="contactformdiv" style="position:absolute; left:147px; top:354px; width:452px; height:483px; z-index:3;">
              <form action="http://www.capitolpreservation.com/smail.php" method="post" name="msgform" id="msgform">
                <div>
                  <div align="left"></div>
                  <table width="450" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                    <!-- First tabe row -->
                    <tbody>
                      <tr>
                        <td colspan="3"></td>
                        <!-- second table row -->
                      </tr>
                      <tr>
                        <td width="211" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">First Name</span>
                                  <input maxlength="30" name="fname" size="20" />
                        </font></div></td>
                        <!-- Coloum two in the second table row -->
                        <td width="239" colspan="2" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">Last Name</span>
                                  <input maxlength="30" name="lname" size="20" />
                        </font></div></td>
                      </tr>
                      <!-- Third table row spread over 3 coloumns -->
                      <tr bgcolor="#FFFFFF">
                        <td colspan="3"><div align="left" class="style6"><font face="Tahoma"><span class="style7">Street</span><br />
                                  <input maxlength="70" name="st1" size="70" />
                                  <br />
                                  <input maxlength="70" name="st2" size="70" />
                        </font></div></td>
                      </tr>
                      <tr>
                        <td width="211" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">City</span>
                                  <input maxlength="30" name="city" size="20" />
                        </font></div></td>
                        <td width="239" colspan="2" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">State</span>
                                  <input maxlength="30" name="state" size="20" />
                        </font></div></td>
                      </tr>
                      <tr bgcolor="#FFFFFF">
                        <td colspan="3"><div align="left" class="style6"><font face="Tahoma"><span class="style7">Zip Code</span>
                                  <input maxlength="15" size="10" name="zcode" />
                        </font></div></td>
                      </tr>
                      <tr bgcolor="#FFFFFF">
                        <td colspan="3"><p><span class="style6"><font face="Tahoma"><span class="style7">Country Code </span></font></span>
                                <input maxlength="15" size="10" name="countcode" />
                        </p></td>
                      </tr>
                      <tr bgcolor="#FFFFFF">
                        <td colspan="3"><div align="left" class="style6">
                            <p><font face="Tahoma"><span class="style7">Country</span>
                                  <select name="country">
                                    <option value=" " selected="selected">--- Choose One ---</option>
                                    <option value="Zimbabwe">Zimbabwe</option>
                                  </select>
                            </font></p>
                        </div></td>
                      </tr>
                      <tr>
                        <td width="211" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">Phone Number<font size="1">(INCLUDE AREA CODE)</font></span><br />
                                                          <input maxlength="30" name="pnumber" size="20" />
                        </font></div></td>
                        <td width="239" colspan="2" bgcolor="#FFFFFF"><div align="left" class="style6"><font face="Tahoma"><span class="style7">E-mail Address</span>
                                  <input maxlength="255" name="email" size="20" />
                        </font></div></td>
                      </tr>
                      <tr bgcolor="#FFFFFF">
                        <td height="170" colspan="3"><div align="left" class="style6"><font face="Tahoma"><span class="style7">Enquiry</span><br />
                                  <textarea name="enquiry" rows="10" cols="50"></textarea>
                        </font></div></td>
                      </tr>
                      <tr align="middle" bgcolor="#FFFFFF">
                        <td height="36" colspan="3"><span class="style6"><font face="Tahoma">
                          <input type="submit" value="Submit Enquiry" name="Submit" onclick="return checkForm();"/>
                          <input type="reset" value="Clear Form" name="Reset" />
                        </font></span></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </form>
    	  </div>
    and here is the javascript codes (formcheck.js)

    Code:
    function checkForm()
    {
        var cfname, clname, cst1, ccity, cstate, czcode;
    	var ccountcode, ccountry, cpnumber, cemail, cenquiry;
    	
        with(window.document.msgform)
        {
            cfname = fname;
            clname = lname;
    		cst1 = st1;
    		ccity = city;
    		cstate = state;
    		czcode = zcode;
    		
    		ccountcode = countcode;
    		ccountry = country;
    		cpnumber = pnumber;
    		cemail = email;
    		cenquiry = enquiry;
        }
        
        if(trim(cfname.value) == '')
        {
            alert('Please enter your first name.');
            cfname.focus();
            return false;
        }
        else if(trim(clname.value) == '')
        {
            alert('Please enter your last name.');
            clname.focus();
            return false;
        }
        else if(trim(cst1.value) == '')
        {
            alert('Please enter valid street address.');
            cst1.focus();
            return false;
        }
        else if(trim(ccity.value) == '')
        {
            alert('What city are you? please enter it.');
            ccity.focus();
            return false;
        }
        else if(trim(cstate.value) == '')
        {
            alert('Please enter your state');
            cstate.focus();
            return false;
        }
        else if(trim(czcode.value) == '')
        {
            alert('Please enter your zip code.');
            czcode.focus();
            return false;
        }
        else if(trim(ccountcode.value) == '')
        {
            alert('Please enter your country code.');
            ccountcode.focus();
            return false;
        }
        else if(trim(ccountry.value) == '')
        {
            alert('Please enter your country.');
            ccountry.focus();
            return false;
        }
        else if(trim(cpnumber.value) == '')
        {
            alert('Please enter your contact number');
            cpnumber.focus();
            return false;
        }
        else if(!isEmail(trim(cemail.value)))
        {
            alert('Please enter a valid email address.');
            cemail.focus();
            return false;
        }
        else if(trim(cenquiry.value) == '')
        {
            alert('Please enter your inquiry.');
            cenquiry.focus();
            return false;
        }
        else
        {
    
    		cfname.value = trim(cfname.value);
            clname.value = trim(clname.value);
            cst1.value = trim(cst1.value);
    		ccity.value = trim(ccity.value);		
    		cstate.value = trim(cstate.value);				
    		czcode.value = trim(czcode.value);		
    		ccountcode.value = trim(countcode.value);				
    		ccountry.value = trim(ccountry.value);		
    		cpnumber.value = trim(cpnumber.value);		
            cemail.value = trim(cemail.value);
    		cenquiry.value = trim(cenquiry.value);		
            return true;
        }
    }
    
    /*
    Strip whitespace from the beginning and end of a string
    Input : a string
    */
    function trim(str)
    {
        return str.replace(/^\s+|\s+$/g,'');
    }
    
    /*
    Check if a string is in valid email format. 
    Returns true if valid, false otherwise.
    */
    
    function isEmail(str)
    {
        var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
        return regex.test(str);
    }

    thank you very, very, very, very much in advance...........!!!!!!!!

  2. #2
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    933
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    i already solve this.
    no need to reply.

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you're assigning an undefined variable (countcode) in this line:
    Code:
    ccountcode = countcode;
    Try this instead:
    Code:
    ccountcode = document.getElementById("countcode");
    Then assign an id attribute to the HTML-element:
    HTML Code:
    <input maxlength="15" size="10" id="countcode" name="countcode" />


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
  •