Hi All,
I'm doing a validation before printing. What I'm trying to do is to validate if the JobCard field has a numerical length less than or more than 12, alert user but it wont alert. Second validation is that once it has verified that the number length = 12 then check if the number entered starts with 5300100 or 5300200 then pint, for doing this I don't know what code to use.
This is the only code I could work out on my own:
if (this.resolveNode("JobCard").value < 12 || this.resolveNode("JobCard").value > 12){
xfa.host.message("Invalid Value")
}
Sorry but I'm not a programmer. I have set the JobCard field as float (so when number is entered it wont use a coma separator if more than 4 numbers) and not integer.
Also is there a way to not show the Print Cancelled dialog box that shows automatically when print is cancelled.
Thank You
Solved! Go to Solution.
Views
Replies
Total Likes
convert int to string and use the length method.
var a = this.rawValue; //value from numeric field
var newValueLength = a.toString().length; // converting int to String using toString() method
app.alert(newValueLength); // printing the length of string
Hope this helps.
Thanks
Views
Replies
Total Likes
Hope the langauge selected is "FormCalc"
Try using:
if (this.resolveNode("JobCard").value < 12 || this.resolveNode("JobCard").value > 12)
{
xfa.host.messageBox("Invalid Value");
}
Thanks
Views
Replies
Total Likes
HI Sir,
Thanks, I meant it wont alert as it wont validate and alert, in rush I typed wrong code for messagebox.
What I'm looking for is is the code that will be used to check if the length of the numbers entered is 12 or not, like .value or .length or anything else but both of them dont work
Sorry and Thank You
Views
Replies
Total Likes
convert int to string and use the length method.
var a = this.rawValue; //value from numeric field
var newValueLength = a.toString().length; // converting int to String using toString() method
app.alert(newValueLength); // printing the length of string
Hope this helps.
Thanks
Views
Replies
Total Likes
Dear Sir,
Thank You So Much.
In this case after verifying the number of characters how to verify that the string customer entered starts with the number 5300100 or 5300200 ?
Appreciate your help in the matter
Views
Replies
Total Likes
Hi Sir,
Is it that now we have converted the int to string we can use the substr and verify if the string input is containing 5300100 or 5300200, or there is some other way to confirm the entered value contains 5300100...
Thank you
Views
Replies
Total Likes
Thank You Sir,
Its was what I was looking for.
Much Appreciate it.
Views
Replies
Total Likes
Hi Sir,
Thank You So Much, its validating as I want it but there is one issue:
var a = this.rawValue; //value from numeric field
var newValueLength = a.toString().length; // converting int to String using toString() method
var chkLoc - a.toString().substr(0, 7) // to check for specific number in the JobCard field
Now if I run the above code it works fine and shows the first 7 characters in msgbox and when combined the .length and .substr to run check it works and check if its less than 12 and has 5300100 etc, but the when I add code to validate before print for empty field, the code fails as , so:
if (newValueLength !== 12 || chkLoc !== "5300100" || chkLoc !== "5300200"){
app.alert("Invalid Value")
}
the above code works fine, but when in this case a validation for empty field wont happen even though JobCard field is empty the !==12 doesn't work, so:
if (newValueLength !== 12 || chkLoc !== "5300100" || chkLoc !== "5300200" || newValueLength == 0 || newValueLength == "" ||newValueLength == null){
app.alert("Invalid Value")
}
the above code doesn't work at all, nothing happens and it shows the print dialogbox which it shouldn't since the JobCard field is empty, any idea.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies