Community Forums 

Main Content

Required Fields

    Mar 13 2014 09:45:34

    #1

    Simon Clay

    Join date : 2009-02-19      Posts : 43

    Hi Have a simple form with two fields for the customer to fill in, where they enter the invoice number and invoice amount:

    <input name="product" id="product" type="text">
    <input type="text" id="price" name="price" />

    How can I make these fields 'Required'?



    Mar 13 2014 11:36:01

    #2

    GT

    Join date : 2008-09-18      Posts : 3207

    Use javascript...

    <script type="text/javascript">
    //<![CDATA[
    function check(formname, submitbutton) {
    var errors = '';
    errors += checkText(formname, 'product', 'Your invoice number');
    errors += checkText(formname, 'price', 'The invoice amount');
    checkThisForm(formname, submitbutton, errors);
    }
    }
    //]]>
    </script>


    Add this to your form line:

    name="form1" id="form1"

    Add this to your submit button...

    onclick="check('form1', this.name);" onkeypress="check('form1', this.name);"

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Mar 13 2014 12:37:30

    #3

    Simon Clay

    Join date : 2009-02-19      Posts : 43

    Thanks very much GT