Web Analytics Made Easy -
StatCounter Form Validation - CodingForum


No announcement yet.

Form Validation

  • Filter
  • Time
  • Show
Clear All
new posts

  • Form Validation

    I am attempting to write JavaScript for form validation on a form I have created . I have 2 x examples of the JavaScript I would like to use at my home page (see URL) Refer to "Project 03". Please give me your feedback on why these are not working? Also, take into account that I will be needing to write JavaScript for the entire form (checkboxes, radio buttons, dropdown options etc,) I want to go with a JavaScript style that allows me to enhance (numeric, alpha, email, max/min length etc) as I learn.

    Also I am not sure why the 'Submit' button on the form is not making the usual click sound?
    Last edited by meteor; Feb 23, 2004, 08:19 AM.

  • #2
    OK: I think your main problem is that, viewing the source of http://au.geocities.com/tombob_au/Project03.html, the HTML is - for want of a better word - screwed. Taking the first few lines as an example:
    <title>Online Order Form</title>
    <p><font face="verdana">
    <font color="00ff00"><font size="+3"><center><b>Joe's Fruit Shop - Online Order Form</b></font color></font size>
    <body bgcolor="9aff9a">
    <! the whole page is a form
    <form name="order form">
    1. You have html content outside the <body> tag.
    2. The HTML comment should be thus: <!-- this is a comment -->
    The "<!" seems to be causing an error.
    3. </br> isn't a tag. Neither is </hr>. For tags without closing tags, the correct XHTML-compliant markup is <br />
    4. </font color> isn't a tag either. Use </font> to close a font tag, regardless of what attributes you have in the opening tag. Or better still, bear in mind that the <font> tag is depreciated and start using CSS.

    There are a myriad of other errors; the correct "form reset" button, for example, is <input type="reset" value="Clear">, and not <input type="submit" name="cf" value="Clear">, as you have at the moment.

    I also can't find any javascript on that page. Is there supposed to be?

    Take some time to read up on HTML at places like www.w3schools.com and run your code through HTML validators like that at www.w3c.org

    Hope that helps.
    Last edited by Spudhead; Feb 23, 2004, 10:59 AM.


    • #3

      Thanks for getting back to me. I read you on all points except </font color>. I tried just using </font> and the font color continued throughout the rest of the form (I only want it for heading).


      • #4
        Yeah, that's because you have multiple font tags.

        If you've got:

        <font color="00ff00"><font size="+3"><center><b>Joe's Fruit Shop - Online Order Form</b></font color></font size>

        and you replace it with

        <font color="00ff00"><font size="+3"><center><b>Joe's Fruit Shop - Online Order Form</b></font>

        then you've only closed the font tag that specifies size. You need to add another </font> tag on the end to close off the font tag that specifies color.

        Or you can chuck all your attributes into one tag and have
        <font color="00ff00" size="+3"><center><b>Joe's Fruit Shop - Online Order Form</b></center></font>

        But seriously - avoid font tags. Use CSS.


        • #5

          Cheers dood. Is my JavaScript likely to work now that I've redone my HTML ? (will update font tag also)