Results 1 to 10 of 10

Thread: Required fields containing default text

  1. #1
    Join Date
    Oct 2004
    Posts
    27

    Default Required fields containing default text

    I have some fields with default text, for example:

    <input name="DOB_Day" type="text" value="Day" size="4" maxlength="3">

    This box says 'Day' so users know to type the Day in there, rather than Month or Year.

    However, having a default value means that the fields are not recognised as Required fields, as they already have data in them.

    Is there any way round this?

    Thanks

  2. #2
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Required fields containing default text

    Hi,

    Yes. You need to use conditions. These are documented in formmail.php, but this will get you started for your "Day" test:

    Code:
    <input type="hidden" name="conditions1" value=":@
    	 @TEST@DOB_Day !~ /Day/@Please enter a day name for your DOB@" />
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Oct 2004
    Posts
    27

    Default Re: Required fields containing default text

    Hello again

    I thought I had it working... I've attached a copy of sampleform.html with a DOB_day field as an example - I haven't been able to make the condition work for the field on this page. Clicking on submit without entering any values at all just brings up two messages:

    The form required some values that you did not seem to provide.
    Your email address
    Your name
    Thanks for your help.

    Lucy
    Attached Files Attached Files
    Last edited by tvulucy; 05-Oct-2004 at 12:20 PM.

  4. #4
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Required fields containing default text

    Hi,

    Required fields are checked before conditions. If required fields are missing, then FormMail reports those errors before even checking the conditions.

    If you fill in the the name and email without setting DOB_Day, you should get the message you're looking for.

    If you want the failed conditions reported at the same time as the required fields, you can put the required fields test in with the conditions instead of using the "required" feature.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Oct 2004
    Posts
    27

    Default Re: Required fields containing default text

    Brilliant. I've turned all the required fields into conditions instead and it works perfectly.

    Actually, to save me racking my brains for too long, do you have a ready-made condition for checking whether an email address is 'structurally' valid? (eg has a '@' sign and a 'dot something' at the end)

    Thanks
    Lucy

  6. #6
    Join Date
    Dec 2003
    Posts
    3,980

    Thumbs up Re: Required fields containing default text

    Hi,

    I don't guarantee that this is perfect, but here's a reasonable attempt at checking for valid email address:

    Code:
    <input type="hidden" name="conditions" value=":#
     #TEST#email ~ /^[a-z0-9_.]+@[a-z0-9_]+\.([a-z0-9_.]+)*[a-z0-9_.]$/i #
     Please enter a valid email address.#">
    Hope that helps!
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  7. #7
    Join Date
    Oct 2004
    Posts
    27

    Default Re: Required fields containing default text

    On a related note... how do I apply conditions to a list box, eg:
    <select name="Title">
    <option value="Please select" selected>Please select</option>
    <option value="Mr">Mr</option>
    <option value="Mrs">Mrs</option>
    <option value="Miss">Miss</option>
    </select>
    SOLVED: I've managed to answer my own question - I had the !~ the wrong way round in the conditions test. doh.
    Last edited by tvulucy; 06-Oct-2004 at 12:45 PM.

  8. #8
    Join Date
    Oct 2004
    Posts
    27

    Default Re: Required fields containing default text

    Hello again

    Am I correct in deducing that you can only have a maximum of 18 tested fields?

    I have about 23 different fields that need testing, but once the user has filled in the first 18 required fields, the other 5 aren't tested and the form is submitted without errors.

    Combining fields in one TEST (eg #TEST#FirstName|Surname#Your full name#: ) doesn't make a difference - it's the number of fields, not the number of TEST conditions

    Is there a way to adjust this?

    Thanks
    Lucy

  9. #9
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Required fields containing default text

    Hi,

    No, there's no limit within FormMail on the number of fields that can be tested.

    The most likely cause is a syntax error in your conditions statement.

    FormMail should detect such an error and report it to you, but maybe it's missing it too.

    Can you send me the URL for your form? I'll take a quick look at it.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  10. #10
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Required fields containing default text

    Hi,

    The problem is that the conditions field is being truncated.

    This is caused by a security feature in FormMail.

    Look for the setting called MAXSTRING. It is 1024 by default and your long conditions field is being truncated by that.

    You can increase the value to resolve the problem.

    Or, better still, use multiple conditions fields. Like this:

    Code:
    <input type="hidden" name="conditions1" value="..." />
    <input type="hidden" name="conditions2" value="..." />
    <input type="hidden" name="conditions3" value="..." />
    Each conditions field can have multple tests (and will be truncated to MAXSTRING bytes - so keep them below that).

    There's no limit to the number of conditions fields you can specify.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PlainTemplate feature - formatting your plain text email
    By russellr in forum HOWTO Guides and Tips
    Replies: 7
    Last Post: 03-Mar-2005, 12:08 PM
  2. Required Fields not working?
    By zoe77 in forum FormMail Subscription Support
    Replies: 2
    Last Post: 02-Jun-2004, 04:27 PM
  3. Deriving fields from other fields
    By russellr in forum HOWTO Guides and Tips
    Replies: 0
    Last Post: 13-May-2004, 12:25 PM
  4. required field error
    By Ibis in forum FormMail Subscription Support
    Replies: 18
    Last Post: 02-Mar-2004, 09:04 AM
  5. required does not work ?!
    By flynst4r in forum FormMail Subscription Support
    Replies: 9
    Last Post: 26-Jan-2004, 09:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •