Skip navigation
blakedodson.prg
Currently Being Moderated

Validation Code Confusion

May 3, 2012 2:07 PM

Tags: #acrobat_10_pro

Why doesn't this validation code work?  if(event.value == 135.31 | event.value == '') event.value = '';

 

It works if I don't use 135.31 and I only use 125, but I don't want it to show this particular dollar amount.  I don't know Java script at all, I copied most of this code from another forum.  Any ideas?  I can send the form I've created if that helps.

 

Blake Dodson

bdodson@prg.com

 

Thanks,

 
Replies
  • Currently Being Moderated
    May 3, 2012 2:19 PM   in reply to blakedodson.prg

    The second part of the if condition is not required. If the value is

    already blank, why reset it?

    Try this instead:

    if (event.value == "135.31") event.value = "";

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 3:49 PM   in reply to blakedodson.prg

    Why are you using the Bitwise OR and not the Logical OR?

     

    The bitwise operators only process 32 bits of the the data string and not the entire floating point  number.

     

    I would also use the valueAsString property to test for the null string character, the value property sometimes treats the null character as a zero not a null string..

     

    if(event.value == 135.31 || event.valueAsString == '') event.value = '';

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 5:46 AM   in reply to blakedodson.prg

    You can use the JS console to find out what's the exact value of the field.

    Just execute this code:

    this.getField("Field Name").valueAsString

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 8:43 AM   in reply to blakedodson.prg

    if (this.getField("Field1").value == "0") event.value = "";

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points