Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery.validator.addMethod("codiceFiscale",function(value) {
- var regex = /[A-Z]{6}[\d]{2}[A-Z][\d]{2}[A-Z][\d]{3}[A-Z]/;
- return (value.match(regex))
- },"codice fiscale sbagliato");
- $().ready(function(){
- $("#form").validate({
- rules:{
- nome: {
- required: true
- },
- codiceFiscale: {
- required: true
- },
- telefono: {
- required:true
- },
- email: {
- required: true
- },
- password: {
- required:true
- },
- confermapassword: {
- required: true,
- equalTo: "#password"
- }
- },
- messages:{
- nome: {
- required: "nome"
- },
- telefono: "telefono non valido!",
- codicefiscale: {
- required: "codice fiscale"
- },
- email: "formato email non valido!",
- password: {
- required: "Inserisci una password!",
- minlength: "La password deve essere lunga minimo 4 caratteri",
- maxlength: "La password deve essere lunga al massimo 8 caratteri"
- },
- confermapassword: "la password non corrisponde!"
- },
- submitHandler: function(form){
- form.submit();
- },
- });
- });
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="css/bootstrap.min.css">
- <title>Document</title>
- </head>
- <body style="background-color:#efefef">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <script src="jqueryscript.js"></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement