Problem with select validation
Where is mistake ?
- $(function () {
$(":text, :password").bind("focus blur", function (event) {
if (event.type == "focus") {
$(this).css("border","2px solid #4C70AF");
} else {
$(this).css("border","");
}
});
var validator = $("#reportForm").validate({
rules: {
utente: {
required: true
}
},
messages: {
utente: "<span style='color:#ff0000;'>Please,select a city</span>"
},
errorPlacement: function(error, element) {
if ( element.is(":radio") )
error.appendTo( element.parent().next().next() );
else if ( element.is(":checkbox") )
error.appendTo ( element.next() );
else{
error.appendTo( $("#test") );
}
}
});
});
To validation (I have not a submit button)
- function submit(){
$("#reportForm").submit()
}
HTML code
- <form name="form" id="reportForm">
<p>
<label class="labelFiltro" for="utente">Utente/Operatore</label>
<select name="utente" id="utente">
<option value="">Scegli ....</option>
<option value="1">pippo</option>
<option value="2">pluto</option>
</select>
<div id="test"></div>
</p>
- <div class="bottoni" >
<a class="bottone" href="" onclick="submit();">
<img title="" alt="" src="images/bottone-left.gif" class="img-bottone-sx">
<span class="sp-bottone-centro">submit</span>
<img title="" alt="" src="images/bottone-right.gif" class="img-bottone-dx">
</a>
</div>
- </form>