http://www.tohub.it:8085/demo/form.php
form.js (convalidazione)
codice:
// JavaScript Document
$(document).ready(function (){
$("#confBsi").click(
function(){
$('#primo').fadeOut(1)
$('#content').fadeIn(1)
}
)
$("#confBno").click(
function(){
$('#primo').fadeOut(1)
$('#content2').fadeIn(1)
}
)
$("#allergieali").change(function() {
// foo is the id of the other select box
if ($(this).val() == "altro") {
$("#alalalok").show();
}else{
$("#alalalok").hide();
}
});
$("#trasferimento").change(function() {
// foo is the id of the other select box
if ($(this).val() == "si") {
$("#hidecittpart").show();
}else{
$("#hidecittpart").hide();
}
});
});
$(document).ready(function () {
$('#formElem').validate({ // initialize the plugin
rules: {
nome: {
required: true
},
cognome: {
required: true
},
cellulare: {
required: true
},
mail: {
required: true
},
ldn: {
required: true
},
ddn: {
required: true
},
tdd: {
required: true
},
ndoc: {
required: true
},
rdoc: {
required: true
},
edoc: {
required: true
},
sdoc: {
required: true
},
allergieali: {
required: true
},
cdp: {
required: true
}
},
messages: {
nome: "Campo vuoto",
cognome: "Campo vuoto",
cellulare: "Campo vuoto",
mail: "Campo vuoto",
ldn: "Campo vuoto",
ddn: "Campo vuoto",
tdd: "Campo vuoto",
ndoc: "Campo vuoto",
rdoc: "Campo vuoto",
edoc: "Campo vuoto",
sdoc: "Campo vuoto",
allergieali: "Campo vuoto",
cdp: "Campo vuoto",
},
});
$.validator.addMethod("dateHigherThanToday", function(value, element) {
var fullDate = new Date();
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1);
var currentDate = fullDate.getDate() + "-" + twoDigitMonth + "-" + fullDate.getFullYear();
console.log(currentDate);
console.log(value);
var myDate = value;
return Date.parse(myDate) < currentDate;
}, "Date must be higher than current date");
});
Spero si capisca... Grazie!