The validation is only triggered during submit event which is fine to
me.  I don't like interactive validation as it creates distraction to
the users.

            $("form").validate(
            {
                errorLabelContainer: "#errMsg",
                wrapper: "li"
            });

            $("#phoneCount").rules("add", {
                min: 1,
                messages: {
                    min: 'A contact number is required.'
                }
            });

            $("#business, #fax, #cell, #home").change(function() {
                if ($(this).val() != '')
                    changeCounter(this,1);
                else
                    changeCounter(this,-1);
            });

        });

        function changeCounter(calleer, i)
        {
            var curVal = parseInt($("#phoneCount")[0].value,10);

            $("#phoneCount")[0].value = curVal + i;
        }

    <input type="hidden" id="phoneCount" name="phoneCount" value="0" /
>
    <div>
        <label>Business:</label><input type="text" id="business"
name="business" /><br />
        <label>Home:</label><input type="text" id="home" name="home" /
><br />
        <label>Cell:</label><input type="text" id="cell" name="cell" /
><br />
        <label>Fax:</label><input type="text" id="fax" name="fax" /
><br />
    </div>
    <input type="submit" id="btnSubmit" name="btnSubmit"
value="Submit" />


On Jul 23, 3:19 am, kmac <lucie.friga...@gmail.com> wrote:
> Hi,
>
> I have a form that includes four text fields for phone numbers:
> Business, Home, Cell and Fax
>
> A user must fill in at least one phone number.
>
> How would I set up the validation for this?
>
> Cheers

Reply via email to