Hi Volks,
I have a pdf form with few date fields (weekdays), and a button what is chek these datefields. here is the code:
if ((xfa.resolveNode("date_m[1]").rawValue == null) || (xfa.resolveNode("date_m[1]").rawValue == "")) {
app.alert("Check the date fields from Monday to Friday!");
}
else if ((xfa.resolveNode("date_m[2]").rawValue == null) || (xfa.resolveNode("date_m[2]").rawValue == "")) {
app.alert("Check the date fields from Monday to Friday!");
}
else if ((xfa.resolveNode("date_m[3]").rawValue == null) || (xfa.resolveNode("date_m[3]").rawValue == "")) {
app.alert("Check the date fields from Monday to Friday!");
}
else if ((xfa.resolveNode("date_m[4]").rawValue == null) || (xfa.resolveNode("date_m[4]").rawValue == "")) {
app.alert("Check the date fields from Monday to Friday!");
}
else if ((xfa.resolveNode("date_m[0]").rawValue == null) || (xfa.resolveNode("date_m[0]").rawValue == "")) {
app.alert("Check the date fields from Monday to Friday!");
}
else {
app.alert("Dates OK!");
}
The intresting thing is that the date_m[0] is not working (if this one is empty or not), I get the same result: "Dates Ok", and I dont know why...
If I delete the last else if part (with the date_m[0]) everithing working perfectly....
What can be the problem?
Thanks,
encleadus
Solved! Go to Solution.
Views
Replies
Total Likes
Ya that is weird it shouldn't be doing that. Try using this script:
if (hasEmpty(date_m))
xfa.host.messageBox("Check the date fields from Monday to Friday!");
else
xfa.host.messageBox("Dates OK!");
function hasEmpty(oField){
for (var a=0;a<oField.all.length;a++){
if (oField.all.item(a).isNull || oField.all.item(a).rawValue=="")
return true;
}
return false;
}
Kyle
Views
Replies
Total Likes
Ya that is weird it shouldn't be doing that. Try using this script:
if (hasEmpty(date_m))
xfa.host.messageBox("Check the date fields from Monday to Friday!");
else
xfa.host.messageBox("Dates OK!");
function hasEmpty(oField){
for (var a=0;a<oField.all.length;a++){
if (oField.all.item(a).isNull || oField.all.item(a).rawValue=="")
return true;
}
return false;
}
Kyle
Views
Replies
Total Likes
Hi, thanks for the help. I will check it, but I am on site at the moment.
Encleadus
Views
Replies
Total Likes
Thanks for this code, is working perfectly.
Can you change a littlebit for me please, because it is include the weekends as well, and these are can be blank. I cannot change the field names becase I builded up a full batch processing to insert the form data into a database...
The weekend fields are date_m[5] and date_m[6].
Thanks in advance.
encleadus
Views
Replies
Total Likes
Replace oField.all.length with 5.
Kyle
Views
Replies
Total Likes
Thanks Kyle,
This one is worked great as well!
encleadus
Views
Replies
Total Likes
I don't understand this livecycle (perhaps, because I am not a programer).... I think this is a software bug.
The problem is the same. If you have any time capacity can you chek this code, please?
if ((xfa.resolveNode("hours_m1[0]").rawValue) + (xfa.resolveNode("hours_m2[0]").rawValue)+ (xfa.resolveNode("hours_m3[0]").rawValue)+ (xfa.resolveNode("hours_m4[0]").rawValue)+ (xfa.resolveNode("hours_m5[0]").rawValue)+ (xfa.resolveNode("hours_m6[0]").rawValue)+ (xfa.resolveNode("hours_m7[0]").rawValue)+ (xfa.resolveNode("hours_m8[0]").rawValue) == (xfa.resolveNode("standardhours_m[0]").rawValue) + (xfa.resolveNode("overtime6_m[0]").rawValue)+ (xfa.resolveNode("overtime10_m[0]").rawValue)) {
}
else {
app.alert("Monday: Activity hours are not equal with Standard, Overtime, Nightshift/Weekend hours.");
}
if ((xfa.resolveNode("hours_m1[1]").rawValue) + (xfa.resolveNode("hours_m2[1]").rawValue)+ (xfa.resolveNode("hours_m3[1]").rawValue)+ (xfa.resolveNode("hours_m4[1]").rawValue)+ (xfa.resolveNode("hours_m5[1]").rawValue)+ (xfa.resolveNode("hours_m6[1]").rawValue)+ (xfa.resolveNode("hours_m7[1]").rawValue)+ (xfa.resolveNode("hours_m8[1]").rawValue) == (xfa.resolveNode("standardhours_m[1]").rawValue) + (xfa.resolveNode("overtime6_m[1]").rawValue)+ (xfa.resolveNode("overtime10_m[1]").rawValue)) {
}
else {
app.alert("Tuesday: Activity hours are not equal with Standard, Overtime, Nightshift/Weekend hours.");
}
thanks,
encleadus
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies