Hello everybody!
I'm trying to use a custom method for validate one of my input's form,
but no way.
Neither the 'additional-methods.js' included in the plugin pack work
for me ....Seems to be ok, but no idea.
This is a resume of my code:
-JAVASCRIPT-
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() {
$("#cForm").ajaxSubmit({
url:'inc/request.php',
target: '#form-box',
success: function(){
return false;
},
resetForm: true
});
}
});
$(document).ready(function(){
$("#cForm").validate({
rules:{
nif: "alphanumeric",
},
messages: {
nombre: "campo obligatorio",
email: {
required: "campo obligatorio",
email: "email no valido"
},
telefono: {
required: "campo obligatorio",
digits: "solo numeros"
},
nif: "campo obligatorio",
legal: "campo obligatorio"
},
errorElement: "em",
errorPlacement: function(error, element) {
if ( element.is(":radio") )
error.appendTo(element.parent().parent());
else if ( element.is(":checkbox") )
error.appendTo(element.parent());
else
error.prependTo( element.parent() );
}
});
});
</script>
-HTML-
...
<form action="" method="post" id="cForm">
<div>
<label for="nombre">Nombre y Apellidos</label>
<input class="required" type="text" size="25"
name="nombre" id="nombre" value="" maxlength="100"/>
</div>
<div>
<label for="nif">NIF</label>
<input class="required" type="text" size="9"
name="nif" id="nif" value="" maxlength="9"/>
</div>
<div>
<label for="telefono">Teléfono</label>
<input class="required digits" type="text"
size="10" name="telefono" id="telefono" value="" maxlength="15"/>
</div>
<div>
<label for="email">E-mail</label>
<input class="required email" type="text"
size="25" name="email" id="email" value="" maxlength="100"/>
</div>
<div class="row">
<input class="required" name="legal" id="legal"
type="checkbox"/>
<label for="legal">He leído y acepto las bases
legales</a></label>
<input type="submit" name="submit" id="send"
value="" />
</div>
</form>
...
Thanks in advance!
Best Regards,
Andrea