Expand my Community achievements bar.

SOLVED

Mimimum/Maximum Check and Specific Value check in textfield

Avatar

Former Community Member

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

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

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

View solution in original post

7 Replies

Avatar

Former Community Member

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

Avatar

Former Community Member

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

Avatar

Correct answer by
Former Community Member

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

Avatar

Former Community Member

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

Avatar

Former Community Member

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

Avatar

Former Community Member

Thank You Sir,

Its was what I was looking for.

Much Appreciate it.

Avatar

Former Community Member

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.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----