The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
in rsv.js form name - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Form Validation: JS + PHP (https://forums.formtools.org/forumdisplay.php?fid=18) +--- Thread: in rsv.js form name (/showthread.php?tid=2797) |
in rsv.js form name - johnbleck2 - Dec 31st, 2013 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; } } RE: in rsv.js form name - johnbleck2 - Jan 1st, 2014 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. |