Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Placeholders are being validated via jQuery Validation before user interaction

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #156720
    theograd
    Participant

    I have placeholders on my input fields that are being validated before the user even does anything.

    http://rsatestamls.kaliocommerce.com/Register.aspx

    Any ideas on fixing?

    Thanks.

    #156725
    Alen
    Participant

    You have the validate kick in on document.ready, shouldn’t you only call this when user submits the form by adding event handler to the submit button.

    #156728
    theograd
    Participant

    At the expense of sounding clueless, how would I fire an event handler on the submit button?

    #156729
    Alen
    Participant

    Since you’re using jQuery take a look at .submit() http://api.jquery.com/submit/

    #156802
    theograd
    Participant

    Trying to use the .submit method on my checkout page real quick.

    This is what I’ve got, but it doesn’t fire:

    <script>
    $(document).ready(function(){
    $("#Method input:checkbox").change(function() {
    if (this.checked) {
    var checkname = $(this).attr("name");
    $('input[type=checkbox][id=OnAccount]').prop('value', 'True')
    $("input:checkbox[name='" + checkname + "']").not(this).removeAttr("checked");
    } else {
    $('input[type=checkbox][id=OnAccount]').val('No');
    }
    });
    $("#CheckoutOptions input:checkbox").change(function() {
    if (this.checked) {
    var checkname = $(this).attr("name");
    $("input:checkbox[name='" + checkname + "']").not(this).removeAttr("checked");
    }
    });
    });
    
    $("#CheckOut").submit(function( event ) {
    alert( "Handler for .submit() called." );
    jQuery.validator.setDefaults({
    debug: false,
    success: "valid"
    });
    $("#CheckOut").validate({
    rules: {
    FirstName: {
    required: true
    },
    LastName: {
    required: true
    },
    Email: {
    required: true,
    email: true
    },
    Phone: {
    required: true,
    digits:true
    },
    Address1: {
    required: true
    },
    City: {
    required: true
    },
    PostalCode: {
    required: true,
    digits: true
    },
    Country: {
    required: true
    },
    State: {
    required: true
    },
    pwd: {
    required: true
    },
    pwd_confirm: {
    required: true
    },
    FName_SHIP: {
    required: true
    },
    LName_Ship: {
    required: true
    },
    Phone_Ship: {
    required: true,
    digits: true
    },
    Address1_Ship: {
    required: true
    },
    City_Ship: {
    required: true
    },
    PostalCode_SHIP: {
    required: true,
    digits: true
    },
    COUNTRY_SHIP: {
    required: true
    },
    State_SHIP: {
    required: true
    },
    NameOnCard: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    CreditCardType: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    CardNumber: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    CardExpMonth: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    CardExpYear: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    CVC: {
    required:{
    depends: function(element) {
    return $("#CCMethod").is(":checked");
    }
    }
    },
    customernumber: {
    required:{
    depends: function(element) {
    return $("#OnAccount").is(":checked");
    }
    }
    }
    }
    });
    });
    populateCartTotal();
    </script>
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.