FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
in rsv.js form name
#1
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;
}
}
Reply
#2
Well, I answered my own question.
it was the form name that was the problem.
It's an internal form tools form. The obvious answer I initially disregarded as it being a variable and not the form name. Alas, sometimes the simplest answer is correct.

var fielddate = document.edit_submission_form.Date_Of_Birth.value;

edit_submission_form was the answer I was looking for.

This wouldn't be the first time I answered my own question. I gotta start waiting a little longer before posting for help. Meanwhile I hope this helps someone along the way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)