Results 1 to 4 of 4

Thread: Validate number of characters in a TextArea field

  1. #1
    Join Date
    Dec 2004
    Posts
    23

    Default Validate number of characters in a TextArea field

    Hi,

    Can I use formmail to check that only a certain number of characters are entered into specific TextArea fields? How would I do this?

    Thanks.

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

    Default Re: Validate number of characters in a TextArea field

    Hi,

    Yes, you can use the conditions feature:
    Code:
    <input type="hidden" name="conditions" value=":@
    	 @TEST@comments ~ /^(.{0}|.{10,})$/ms @
    		  Your comment must be at least 10 characers!@">
    This checks that a field called "comments" has either zero characters or at least 10 characters.

    If you don't want the zero test (meaning that the field must be entered with at least 10 characters), use this:

    Code:
    <input type="hidden" name="conditions" value=":@
    	 @TEST@comments ~ /^.{10,}$/ms @
    		  Your comment must be at least 10 characers!@">
    Note the "ms" at the end of the pattern allows the textarea to have newlines entered. These newlines are counted as characters too.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Dec 2004
    Posts
    23

    Default Re: Validate number of characters in a TextArea field

    Hi,


    Thanks for your reply, that is useful. What I'm actually looking for is a maximum number of characters that a user can enter. They can leave the textarea blank or they can add text up to, say, a maximum of 250 characters.

    Thanks again.

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

    Default Re: Validate number of characters in a TextArea field

    Hi,

    OK, this should do it:
    Code:
    <input type="hidden" name="conditions" value=":@
    @TEST@comments ~ /^(.{0}|.{,250})$/ms @
      Your comment must be less than 250 characers!@">
    Notice it's changed from "{10,}" to "{,250}". This now says "any number up to 250".

    So, this should work too:
    Code:
    <input type="hidden" name="conditions" value=":@
    @TEST@comments ~ /^.{,250}$/ms @
      Your comment must be less than 250 characers!@">
    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. Can "Reply To" EM Field be set to email field
    By CWD in forum FormMail Subscription Support
    Replies: 2
    Last Post: 26-Jul-2005, 04:56 AM
  2. Special Characters in Value String
    By hpinson in forum FormMail Subscription Support
    Replies: 4
    Last Post: 24-Mar-2005, 09:04 PM
  3. BR tag appearing in TEXTAREA in HTML email
    By USBobbie in forum FormMail Subscription Support
    Replies: 3
    Last Post: 11-Mar-2005, 05:13 AM
  4. truncated textarea field
    By Loosefast in forum FormMail Subscription Support
    Replies: 6
    Last Post: 08-Oct-2004, 07:42 PM
  5. Limitation on CSV column number?
    By BLFields in forum FormMail Subscription Support
    Replies: 3
    Last Post: 17-Sep-2004, 06:11 AM

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
  •