BugFix#1636; fix the issue where the user could add anything for the birthday of his contacts

pull/23/head
Alexandre Cloutier 2014-03-10 12:05:01 -04:00
parent 31ace947cb
commit cee1e529f8
2 changed files with 25 additions and 4 deletions

View File

@ -37,6 +37,8 @@
"edit" = "edit";
"invalidemailwarn" = "The specified email is invalid";
"invaliddatewarn" = "The specified date is invalid.";
"invalidmonthwarn" = "The specified month is invalid.";
"invalidyearwarn" = "The specified year is invalid.";
"new" = "new";
"Preferred Phone" = "Preferred Phone";

View File

@ -94,15 +94,34 @@ function validateContactEditor() {
alert(_("invalidemailwarn"));
rc = false;
}
var today = new Date();
var yyyy = today.getFullYear();
var byear = $('birthyear');
var bmonth = $('birthmonth');
var bday = $('birthday');
var bdayValue = byear.value + "-" + bmonth.value + "-" + bday.value;
if (bdayValue != "--" && !dateRegex.test(bdayValue)) {
alert(_("invaliddatewarn"));
rc = false;
if(byear.value <= yyyy && (byear.value.length == 4)){
if(bmonth.value <= 12 && bmonth.value >=1){
if(bday.value <= 31 && bday.value >=1){
var bdayValue = byear.value + "-" + bmonth.value + "-" + bday.value;
if (bdayValue != "--" && !dateRegex.test(bdayValue)) {
alert(_("invaliddatewarn"));
rc = false;
}
}
else{
alert(_("invaliddatewarn"));
rc = false;}
}
else{
alert(_("invalidmonthwarn"));
rc = false;}
}
else{
alert(_("invalidyearwarn"));
rc = false;}
return rc;
}