Dec 31st, 2013, 6:02 PM
Ok, this should be a really simple one for someone.
using rules.push("function,dobValidation")
in the rev.js I have to specify the field to look at.
The javascript works when I use a static date using a string. When I try to grab the field it fails. I believe it's due to using the wrong fromname.
so.. that being said: form name in rsv.js would be...
the table name in mysql? - ie: re_form_1
the form name described in the form view? ie: delivery form
Name of the published form file: ie: bndelivery.php?
I'm assuming it's not the form ID: ie: 1
Maybe that's not the problem. I know it all works with the static date and I can't get the error info go to group in with the others (I believe for the same reason)
see // comments in code below.
Thanks ahead of time!!!! Drivin me nuts.
and Happy New Year!
function dobValidation() {
//below commented line does not work. form name suspect
//var fielddateValue = document.re_form_1.Date_Of_Birth.value;
//works fine with a static date!
var fielddateValue = ('11/1/1999');
alert (fielddateValue);
var fielddate = fielddateValue.split('/');
var fieldmonth = (-fielddate[0]);
var fielddays1 = (fielddate[1]);
var fieldyears1 = (fielddate[2]);
var fieldjsdate = new Date(fielddate[2], --fielddate[0], fielddate[1]);
//current date information
var currentDate = new Date();
var theday = currentDate.getDate();
var themonth = currentDate.getMonth();
var theyear = currentDate.getFullYear();
var s = new Date(+fieldjsdate);
alert (fieldjsdate + ' = js date');
var e = new Date(theyear,themonth,theday);
var timeDiff, timeDiff2, days2, years, months, days, hours, minutes, seconds;
years = e.getFullYear() - s.getFullYear();
timeDiff2 = (e - s);
days2 = (timeDiff2/(24*60*60*1000));
//Can't get the error info to come over properly since I can't get the filed valiue.
var errorinfo = ['We are not accepting applications for individuals under 18'];
if (days2 < 6570) {
//I know it should return an array, but it fails due to not retrieving the field value. Meanwhile I'm just returning one letter - I'm surprised it's returning anything as it is.
//The alert alone works for now, but then it's not grouped with the others as it should be.
alert ('We are not accepting applications for individuals under 18'); return (errorinfo);
}
else
{
return true;
}
}
using rules.push("function,dobValidation")
in the rev.js I have to specify the field to look at.
The javascript works when I use a static date using a string. When I try to grab the field it fails. I believe it's due to using the wrong fromname.
so.. that being said: form name in rsv.js would be...
the table name in mysql? - ie: re_form_1
the form name described in the form view? ie: delivery form
Name of the published form file: ie: bndelivery.php?
I'm assuming it's not the form ID: ie: 1
Maybe that's not the problem. I know it all works with the static date and I can't get the error info go to group in with the others (I believe for the same reason)
see // comments in code below.
Thanks ahead of time!!!! Drivin me nuts.
and Happy New Year!
function dobValidation() {
//below commented line does not work. form name suspect
//var fielddateValue = document.re_form_1.Date_Of_Birth.value;
//works fine with a static date!
var fielddateValue = ('11/1/1999');
alert (fielddateValue);
var fielddate = fielddateValue.split('/');
var fieldmonth = (-fielddate[0]);
var fielddays1 = (fielddate[1]);
var fieldyears1 = (fielddate[2]);
var fieldjsdate = new Date(fielddate[2], --fielddate[0], fielddate[1]);
//current date information
var currentDate = new Date();
var theday = currentDate.getDate();
var themonth = currentDate.getMonth();
var theyear = currentDate.getFullYear();
var s = new Date(+fieldjsdate);
alert (fieldjsdate + ' = js date');
var e = new Date(theyear,themonth,theday);
var timeDiff, timeDiff2, days2, years, months, days, hours, minutes, seconds;
years = e.getFullYear() - s.getFullYear();
timeDiff2 = (e - s);
days2 = (timeDiff2/(24*60*60*1000));
//Can't get the error info to come over properly since I can't get the filed valiue.
var errorinfo = ['We are not accepting applications for individuals under 18'];
if (days2 < 6570) {
//I know it should return an array, but it fails due to not retrieving the field value. Meanwhile I'm just returning one letter - I'm surprised it's returning anything as it is.
//The alert alone works for now, but then it's not grouped with the others as it should be.
alert ('We are not accepting applications for individuals under 18'); return (errorinfo);
}
else
{
return true;
}
}