jQuery.noConflict();
ademas reemplace $. por jQuery. y en los archivos jquery.validate.js/jquery.js
Código Javascript
:
Ver original<link rel="stylesheet" type="text/css" media="screen" href="css/milk.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.addMethod(
"selectNone",
function(value, element) {
if (element.value == "none")
{
return false;
}
else return true;
},
"Please select an option."
);
$(document).ready(function() {
// validate signup form on keyup and submit
var validator = jQuery("#form_a").validate({
rules: {
nombres: {
required: true,
minlength: 3
},
apellidos: {
required: true,
minlength: 7
},
cursos: {
selectNone: true
},
},
messages: {
nombres: {
required: "Enter a nombres",
minlength: jQuery.format("Enter at least {0} characters")
},
apellidos: {
required: "Enter a apellidos",
minlength: jQuery.format("Enter at least {0} characters")
},
},
// the errorPlacement has to take the table layout into account
errorPlacement: function(error, element) {
error.prependTo( element.parent().next() );
},
// specifying a submitHandler prevents the default submit, good for the demo
submitHandler: function() {
alert("submitted!");
},
// set this class to error-labels to indicate valid fields
success: function(label) {
// set as text for IE
label.html(" ").addClass("checked");
}
});
// propose username by combining first- and lastname
jQuery("#username").focus(function() {
var firstname = jQuery.("#firstname").val();
var lastname = jQuery.("#lastname").val();
if(firstname && lastname && !this.value) {
this.value = firstname + "." + lastname;
}
});
});
</script>