This is the script that i have, and it works, I just need to add something to it.
if (this.rawValue == "1" && SSN.isNull) {
SSN.mandatory = "error";
app.alert ("Dependents 1 year and older must have a valid SSN to be eligible for Dental coverage.");
this.rawValue == 0;
}
else if (this.rawValue == 1){
SSN.mandatory = "disabled";
}
I need to make this also verify that AgeVerify field is greater than 1. if not return an unchecked box and have pop up message.
in other words, the person has to be 1 year old and have a SSN entered in order to check the box or they get a message saying error and the box does not check. I can't figure out the "greater than 1" code.
Any help is greatly appreciated.
Views
Replies
Total Likes
Hi,
I think you need something like;
if (this.rawValue == "1" && (SSN.isNull || AgeVerify.rawValue < 1))
{
SSN.mandatory = "error";
app.alert ("Dependents 1 year and older must have a valid SSN to be eligible for Dental coverage.");
this.rawValue = 0;
}
else
{
if (this.rawValue == "1")
{
SSN.mandatory = "disabled";
}
}
You will probably also need to add some code in the exit event of SSN and AgeVerify so that this code also gets called if the blank out the SSN or change the Age to less than one, something like;
CheckBox1.execEvent("click");
Just change CheckBox1 to whatever you have called your checkbox.
Regards
Bruce
Views
Replies
Total Likes
When i put this script in, and put like 2 weeks ago as the DOB, i still can't check the dental box unless i have a valid SSN. If they are less than one year, we won't need a SSN.
Views
Replies
Total Likes
Hi,
My code was expecting the user to enter thier age in AgeVerify as a number. If they are entering the date of birth then you can calculate the age with the following code;
var valid = false;
if (this.rawValue == "1")
{
var d = /(\d\d\d\d)-(\d\d)-(\d\d)/.exec(AgeVerify.rawValue);
if (d !== null)
{
var dob = new Date(d[1], d[2]-1, d[3]);
var today = new Date();
var age = today.getFullYear() - dob.getFullYear();
var m = today.getMonth() - dob.getMonth();
if (m < 0 || (m === 0 && today.getDate() < dob.getDate()))
{
age--;
}
if (age >= 1)
{
if (!SSN.isNull)
{
valid = true;
}
}
else
{
SSN.mandatory = "disabled";
valid = true;
}
}
}
else
{
valid = true;
}
if (!valid)
{
SSN.mandatory = "error";
app.alert ("Dependents 1 year and older must have a valid SSN to be eligible for Dental coverage.");
this.rawValue = 0;
}
Hope that helps
Bruce
Views
Replies
Total Likes
AgeVerify has a script that calcualtes the actual age. it is hidden in the form and only there for calculation purposes for this script. So i suppose technically, it does contain an actual age. eg. 31
Views
Replies
Total Likes