validate: Form not validating properly

validate: Form not validating properly

Hello,

I have created the following form with rules etc. but the numberDE does'nt seems to be working. It submits the form when a valid number or float number is not specified. I am not sure what I am doing wrong.

  1. <script type="text/javascript">
    $().ready(function() {
        $("#frmAddProd").validate({
            rules: {
                prod_code: { minlength: 3, maxlength: 6 },
                prod_name: { required: true, minlength: 3, maxlength: 30 },
                prod_description: { maxlength: 245 },
                prod_qty: { minlength: 1, maxlength: 10, number: true },
                prod_price: { required: true, numberDE: true }
            },
            messages: {
                prod_code: "Min. 3 chars. Max. 6 chars.",
                prod_name: "Please specify a valid Product Name",
                prod_description: "A maximum of 255 chars. are allowed.",
                prod_qty: "Min. 1, Max. 10, Digits only.",
                prod_price: "Please specify a valid Price."
            }
        });
    });
    </script>

    <h3 align="center">Add New Product</h3>
    <p align="center">Fields marked with * are required.</p>
    <form class="asnform" id="frmAddProd" method="get" action="add-product.php">
    <table border="0" cellpadding="3" cellspacing="0" align="center">
    <tr>
        <td align="right">Code:</td>
        <td><input id="prod_code" type="text" name="prod_code" value="<?=$_POST["prod_code"]?>" /></td>
    </tr>
    <tr>
        <td align="right">* Name:</td>
        <td><input id="prod_name" type="text" name="prod_name" value="<?=$_POST["prod_name"]?>" /></td>
    </tr>
    <tr>
        <td align="right">* Category:</td>
        <td><select name="prod_catg">
            <option value="0">Select...</option>
            <?=$catgs?>
        </select></td>
    </tr>
    <tr>
        <td align="right">Description:</td>
        <td><textarea  id="prod_description" cols="24" rows="3" name="prod_description"><?=$_POST["prod_description"]?></textarea></td>
    </tr>
    <tr>
        <td align="right">Quantity:</td>
        <td><input id="prod_qty" type="text" name="prod_qty" value="<?=$_POST["prod_qty"]?>" /></td>
    </tr>
    <tr>
        <td align="right">* Price:</td>
        <td><input id="prod_price" type="text" name="prod_price" value="<?=$_POST["prod_price"]?>" /></td>
    </tr>
    <tr>
        <td align="right">Shipping:</td>
        <td><input type="text" name="prod_shipping" value="<?=$_POST["prod_shipping"]?>" /></td>
    </tr>
    <tr>
        <td align="right">Weight:</td>
        <td><input type="text" name="prod_weight" value="<?=$_POST["prod_weight"]?>" /></td>
    </tr>
    <tr>
        <td align="right">Default Picture:</td>
        <td><input type="file" name="prod_pic" size="36" /></td>
    </tr>
    <tr>
        <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2" align="center">Large Description:<br /><textarea style="width:100%;" cols="50" rows="10"></textarea></td>
    </tr>
    </table>
    <p align="center"><input class="submit" type="submit" name="btnAddProd" value="Add Product" /></p>
    </form>








































































Please help me fix.

Thanks.







    • Topic Participants

    • tapan