Validating a Decimal Field

Avatar

Avatar

RoC1909

Avatar

RoC1909

RoC1909

26-04-2011

*** THIS IS A REPOST SINCE I POSTED IN THE WRONG FORUM ***

Hello,

I have a quick question and I hope someone can help me.

I  have a form that contains a table with approximately 10 columns and 20   rows. For two of these columns, the rows (AKA fields) within it are   decimal fields w/ 2 leading and 2 trailing digits. I would like these   fields to ONLY allow a user to enter a number from 1 to 24.(or be left  empty so the range might be 0 to 24), and  if a user attempts to place a  number outside of this range, a validation  message pops up stating so.

I am sure it's easy to do, so if someone can point me in the right direction, I would appreciate it.

Thank you.

View Entire Topic

Avatar

Avatar

RoC1909

Avatar

RoC1909

RoC1909

26-04-2011

Hey Paul,

Based on your previous reply, would integration work like this:

if (This! <> null) {

//Check the value entered
Then ((this.rawValue > 24) || (this.rawValue < 1))
//Value is outside the range
app.alert("You must enter a value between 1 and 24!");
//Clear the field
this.rawValue = "";
//Put the cursor back in the field
xfa.host.setFocus(this);
}

If I add the snippet, the script doesn't validate.

In VBA, I can churn my way through it, but Javascript is insanely foreign.