views:

28

answers:

0

I'm trying to apply validation to a form using following code :

        $("#paiement").validate({
        errorClass: "invalid",
        validClass: "success",
        rules: {
            referenceTypeComplementBancaire: "required",
            banque: {
                required: function(nomBanque){
                    return $('input[name=referenceTypeComplementBancaire]').val() != "CB";
                },
                minlength: 2
            },
            numeroComplementBancaire: {
                required: function(numeroCompl){
                    return $('input[name=referenceTypeComplementBancaire]:checked').val() != "CB";
                },
                number: true,
                minlength: 5
            },
            montantComplementBancaire: {
                required: function(montantCompl){
                    return $('input[name=referenceTypeComplementBancaire]').val() != "CB";
                },
                min: panierTotal
            }
        },
        messages: {
         referenceTypeComplementBancaire: "",
         banque:"",
         numeroComplementBancaire:"",
         montantComplementBancaire:""
        }
    });

As you can see, most inputs are made required if and only if $('input[name=referenceTypeComplementBancaire]').val() != "CB"

In some cases, this form will have two radio buttons, but right now, it only has one... That's pretty straightforward, but IE doesnt seem to understand a thing (or maybe it's me).

My form, once server rendered, looks like this:

<form name="paiementForm" method="post" action="/actions/commande/enregistrerPaiement?time=" id="paiement"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="ee247d689484921c6937972ed50c8165"></div>

    <div class="optionsPaiement">
        <input type="radio" name="referenceTypeComplementBancaire" value="CH2" checked="checked">&nbsp;<strong>Par Chèque</strong>
        <br/>
        <img class="visuelCB" src="/images/logo_CH2.gif" alt="Paiement Carte Bancaire"/>
    </div>          


<div id="infosComplementBancaire">
    <span>Banque<br/>
        <input type="text" name="banque" value="">
    </span>
    <span>Num&eacute;ro de chèque<br/>
        <input type="text" name="numeroComplementBancaire" value="">
    </span>
    <span>Montant du chèque<br/>
        <input type="text" name="montantComplementBancaire" value="507.0">
    </span>
</div>
<input class="bouton" id="terminerPaiement" type="image" src="/images/boutons/valider.gif" alt="Valider"  value="submit" ></input>  

What could i be missing that makes validation work under FF and not in IE 7/6 ?