Could you provide a simplified example that gives focus to the actual
problem here?

Jörn

On Sat, Dec 13, 2008 at 9:16 PM, Jet <webones...@hotmail.com> wrote:
>
> Hi,
>
> It's kind of difficult for me to explain for English is not my native
> language.
>
> I'll explain it briefly and refer you to the actual page.
>
> If the 'Rule' for a field has a "Required" attribute and with or
> without any other attributes, then it works fine.
>
> But when a field has any other 'Rules' attribute other than
> 'Required', and when the field is blank, it updated the
> this.defaultShowErrors(); status but it doesn't update the
> "numberOfInvalids" count (it will show there is (1) error).
>
> Here is the actual page: http://www.thaidatelink.com/page/delivery/
>
> Note1: no need to login to test the page, just click on the Radio or
> Checkbox to display the form.
> Fields without an asterisk sign (not required fields) are those which
> has the problem. Type something into any of the following fields:
> "Recipient's Email:", "Recipient's Telephone: " and "Message: " then
> clear the field, and you shall see that the "this.defaultShowErrors
> ();" staus will be updated as it should but the "numberOfInvalids"
> notify of an error instead though the field isn't a "Required" field.
>
> Hopefully someone could help for I have been trying to solve this
> problem without success for the last three days.
>
> Thanks in advanced.
>
> Below is the code I used on the page:
>
> <script type="text/javascript">
> $.validator.setDefaults({
>        focusInvalid: false
> });
>
> $(document).ready(function(){
> $("#error_summary_float").hide();
> var v = $("#delivery_quotation").validate({
>        rules: {
>                 recipient_member: { required: true },
>                 recipient_username: { required: true,
>                                                 nowhitespace: true,
>                                                 alphanumeric: true,
>                                 minlength: 4,
>                                 maxlength: 16 },
>                 recipient_name: { required: true,
>                           lettersspaces: true,
>                           maxlength: 64 },
>                 recipient_address: { required: true },
>                recipient_email: { email: true,
>                                 nowhitespace: true,
>                                 maxlength: 64 },
>                recipient_phone: { phonenumber: true,
>                                   minlength: 9,
>                                   maxlength: 32 },
>                select_gifts: { required: true },
>                "gifts[]": { required: true },
>                greeting_card_to: { required: true,
>                                            letterswithbasicpunc: true,
>                                    maxlength: 64 },
>                greeting_card_msg: { lettersnumberspuncspaces: true },
>                greeting_card_from: { required: true,
>                                       letterswithbasicpunc: true },
>                instructions_requests: { maxlength: 500 },
>                imgverify: { required: true,
>                        minlength: 5,
>                        nowhitespace: true,
>                        lettersnumbers: true,
>                        lowercaseletters: true }
>                },
>        messages: {
>        recipient_member: { required: "Information required!" },
>        recipient_username: { required: "This field cannot be empty!",
>                        nowhitespace: "No spaces allowed!!",
>                        alphanumeric: "Letters, Numbers & Underscores only!",
>                        minlength: "Minimum 4 characters long!",
>                                maxlength: "Maximum 16 characters long!" },
>        recipient_name: { required: "This field cannot be empty!",
>                                         letterswithbasicpunc: "Letters & 
> Basic Punctuation
> only!",
>                                 maxlength: "Maximum 64 characters long!" },
>        recipient_address: { required: "This field cannot be empty!" },
>        recipient_email: { email: "Please enter a valid Email Address!",
>                         nowhitespace: "No spaces allowed!",
>                         maxlength: "Maximum 64 characters long!" },
>        recipient_phone: { phonenumber: "Numbers, Brackets & Hyphens
> only!",
>                          minlength: "Minimum 9 digits long!",
>                          maxlength: "Maximum 16 digits long!" },
>        select_gifts: { required: "You have not selected any Gift!" },
>        "gifts[]": { required: "Please select at least one item!" },
>        greeting_card_to: { required: "This field cannot be empty!",
>                            letterswithbasicpunc: "Letters & Basic Punctuation
> only!",
>                                    maxlength: "Maximum 64 characters
> long!" },
>        greeting_card_msg: {
>                                lettersnumberspuncspaces: "Letters,
> Numbers & Punctuation only!" },
>        greeting_card_from: { required: "This field cannot be empty!",
>                               letterswithbasicpunc: "Letters & Basic
> Punctuation only!",
>                               maxlength: "Maximum 64 characters long!" },
>        instructions_requests: { maxlength: "Maximum 500 characters
> long!"  },
>        imgverify: { required: "This field cannot be empty!",
>                minlength: "Must be 5 characters long!",
>                nowhitespace: "No spaces allowed!",
>                lettersnumbers: "Letters & Numbers only!",
>                lowercaseletters: "Lowercase letters only!" }
>                },
>        errorPlacement: function(error, element) {
>                if ( element.is(":radio" && "inp...@name='recipient_member']") 
> )
>                        error.appendTo( "#recipient_member_status" );
>                else if ( element.is(":checkbox" && 
> "inp...@name='select_gifts']") )
>                        error.appendTo ( "#select_gifts_status" );
>                else if ( element.is(":checkbox") && $("inp...@name='gifts']") 
> )
>                        error.appendTo ( "#gifts_field_status, #error_fw01, 
> #error_fw02,
> #error_fw03, #error_fw04, #error_fw05, #error_fw06, #error_fw07,
> #error_fw08" );
>                else
>                        error.appendTo ( element.parent().next() );
>                },
>        showErrors: function(errorMap, errorList) {
>        var errors = this.numberOfInvalids();
>        if (errors) {
>        var message = errors == 1
>                ? 'Your form contains <strong>( 1 )</strong> error.<br />Please
> correct the highlighted field in error before submitting this form.'
>                : 'Your form contains <strong>( ' + errors + ' )</strong>
> errors.<br />Please correct the highlighted fields in error before
> submitting this form.';
>                        $("#error_summary").html(message);
>                        $("#error_summary_float").slideDown();
>                        this.defaultShowErrors();
>        } else  {
>                        $("#error_summary_float").slideUp();
>                        this.defaultShowErrors();
>                        }
>                },
>        success: function(label) {
>                        // set   as text for IE
>                        label.html(" ").addClass("checked");
>                }
>        });
>        $("#submit").click(function() {
>          if (v.form())
>                {
>                $('form').nyroModal();
>                }
>        else
>                { return false;
>                }
>        });
>        var recipient_username = $("#fs_recipient_details");
>        var recipient_usernameInputs = recipient_username.find("input,
> textarea").attr("disabled", !inital);
>        var select_gifts = $("#select_gifts");
>        var inital = select_gifts.is(":checked");
>        var gifts = $("#fs_flowers");
>        var giftsInputs = gifts.find("input").attr("disabled", !inital);
>        var greeting_card_to = $("#fs_greeting_card");
>        var greeting_card_toInputs = greeting_card_to.find("input,
> textarea").attr("disabled", !inital);
>        select_gifts.click(function() {
>                giftsInputs.attr("disabled", !this.checked).attr('checked', 
> false);
>                greeting_card_toInputs.attr("disabled", !this.checked).val("");
>         });
> });
> </script>
>

Reply via email to