Skip to content

Instantly share code, notes, and snippets.

@demogar
Created April 5, 2011 18:39
Show Gist options
  • Save demogar/904211 to your computer and use it in GitHub Desktop.
Save demogar/904211 to your computer and use it in GitHub Desktop.
jquery.name.validation
$(document).ready(function() {
// Agregamos un metodo nuevo para revisar el nombre
jQuery.validator.addMethod("check_name", function(value, element, params) {
return this.optional(element) || /^([a-zA-Z'-áéíóúÁÉÍÓÚ]+\s+){1,4}[a-zA-z'-áéíóúÁÉÍÓÚ]+$/i.test(value);
}, jQuery.format("Escribir Nombre + Apellido"));
// Validamos el form
$("#contact_form").validate({
rules: {
nombre: {
required: true,
check_name: true
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment