Support » Plugins » Hacks » Checking form fields for Null entry?

  • I am trying to set some required fields in a PDF file that I will embed in a page. I have the code below:

    event.rc = true;
    if (event.value == ” ” || event.value ==null )
    app.alert(“This is a REQUIRED FIELD’!”);
    event.rc = false;

    If a space is entered it returns the error.
    If the field is just returned through it does not report the error.
    what am I missing in my code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Hmm, I haven’t seriously worked with javascript in a while. IIRC, to check for an ignored field you check for an empty string: event.value == "". So now you’ve checked for ignored field and an empty space. What if there are two spaces? A dot? It’s hard to anticipate what someone may do.

    You may be better off using a regexp to check for a match to what is right instead of trying to anticipate what is wrong. Just a thought, it depends on how important the field is. I’ve found checking for an empty string suffices for client side script. If more rigorous checking is required, it should be done server side. Javascript is inherently insecure.

    bc,you bring up some good points. I’m just trying to reenforce that a few fields are entered, such as Name, Phoone No, etc. There is no real validation because they could enter anything. The point is to make sure they just don’t skip over it and leave it blank. When they walk in the door and it say Dog I can than ask them why they tried to skip a field that was tagged as required.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checking form fields for Null entry?’ is closed to new replies.