These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Validating values between 1 & 4 but also 0, how?

darkaliche
Registered: Jun 13 2007
Posts: 4

Hello,

I'm selling a product in which I'm creating a purchase order form.

We sell the product in cases and depending on the amount, we give a price.

If people buy from 1 to 4 they get a price. From 5 to 8, another price, you get the idea.

I was able to create the form so that when they pick more than allowed (let's say, they type 5 in the field from 1 to 4), they get an error message, however, the data stays and it's still gets added to the rest.

How can I fix this? I want it to become 0 in case they try to put a value that is not allowed.

I have this code right now:

[b]if ( 1 <= this.rawValue && this.rawValue <= 4 ){
}
else{
app.alert("Only 1 thru 4");
this.rawValue = 0;
}[/b]

And it works, but it cannot be 0 because that would show the error.

I want to add in the IF the value of zero.

I know I could do this:

[b]if ( 0 <= this.rawValue && this.rawValue <= 4 ){
}
else{
app.alert("Only 1 thru 4");
this.rawValue = 0;
}[/b]

And all would be good, but how can I do it for, say 10 to 20? If the wrong value is inserted, I want it to become ZERO.

EDIT: I'm using Adobe LiveCycle 8.0

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you tried the "switch (statement){" statement


switch (true) {
case (this.rawValue == 0) :
this.rawValue = "";
break;
case (this.rawValue >= 0 && this.rawValue <= 4) :
// valid input
break;
case (this.rawValue >= 10 && this.rawValue <= 20) :
// valid input
break;
defalut:
this.rawValue = 0;
app.alert("Invalid entry");
break;
}

Currently, I do not have access to LiveCycle Designer, but this does work in Acrobat forms and should work in LC Designer.

George Kaiser

darkaliche
Registered: Jun 13 2007
Posts: 4
My close-minded head wouldn't let me use SWITCH simply because I thought LC wouldn't support it. Thanks