WordPress.org

Ready to get started?Download WordPress

Forums

Checking for a Null field in a form. (7 posts)

  1. LesTexas60
    Member
    Posted 5 months ago #

    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:
    Code:
    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.

  2. catacaustic
    Member
    Posted 5 months ago #

    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.

  3. LesTexas60
    Member
    Posted 5 months ago #

    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.
    :)

  4. catacaustic
    Member
    Posted 5 months ago #

    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

    event.value.length

    If that's not it, then it's not "real" Javascript.

  5. LesTexas60
    Member
    Posted 5 months ago #

    Thanks cat, I'm not adept at JS yet.
    code:
    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?

    thanks

  6. catacaustic
    Member
    Posted 5 months ago #

    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.

  7. LesTexas60
    Member
    Posted 5 months ago #

    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.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.