Support » Fixing WordPress » Checking for a Null field in a form.

  • I’m embedding a PDF type form in a page and I want required fields. The form will be printed and signed rather than emailed. I have a number of required fields so I am putting JS in to edit the fields:
    event.rc = true;
    if (event.value == ” ” || event.value == null )
    app.alert(“This is a REQUIRED FIELD’!”);
    event.rc = false;

    The above catches if a “Space” is entered but not if the field is just returned through.

    Any help is appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • catacaustic


    very awesome

    You might get really lucky and find someone here that can give you an answer, but I wouldn’t hold my breath. We’re WordPress people… Not PDF. You’d have a whole lot more luck asking on a forum that’s more closely dedicated to PDF’s.

    Thanks for the response cat but it’s just the Javascript code I need to validate the field. I’m using PDFill Editor to create an interactive form that I then embedded into a page with a plugin. My example works for the first part of the validation for a space. Seems like there are lots of people in here that are very good coders. I’ve gotten help with shortcodes a number of times. It’s not really specific to PDF’s.



    very awesome

    Well, it sort of is.. but I’ll try to help.

    If it is real Javascript, then the field will have *some* value, even if it’s blank. if it’s blank, the value is an empty string. To check for that, you’d use the .length value from the variable. So it would be something like


    If that’s not it, then it’s not “real” Javascript.

    Thanks cat, I’m not adept at JS yet.
    if (event.value == ” ” || event.value == null )

    I read the above code as if the field value equal a space or if the field value = Nothing. So I need to change it to:

    if (event.valuelength == 0)
    Is that it?




    very awesome

    There’s a . in between value and length.

    BUT, as I said, I cannot guarantee that this will work in a PDF file, as PDF’s are close, but not the same as Javascript that’s used in a normal browser.

    Thanks Cat but no luck. Maybe there is a special value to check for in a PDF. It just seems strange that the check for space works but not for null. I’ll keep looking.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Checking for a Null field in a form.’ is closed to new replies.