Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.10. Features

Validation of field values

JavaScript validation

Example

If you have activated validation JS in constants (default), than you can validate values of textfields just after input in frontend:

Example: Mandatory check

Example: E-Mail check

Check for:

This validation of textfields are currently possible:

  1. Mandatory

  2. E-Mail

  3. URL

  4. Numbers

  5. Numbers (with comma or point)

  6. Letters

  7. Letters and numbers

Error Message:

Note: Current error messages are in german and english – you can change or add your own messages via locallang or typoscript (see above)

Stylesheet classes to manipulate validation messages and input fields:

  1. If error in inputfields: <input class=“validation-failed” />

  2. If no error in inputfields: <input class=“validation-passed” />

  3. DIV Layer of errormessage: <div class=”powermail_mandatory_js”>error</div>

PHP validation

Email of sender

Email of user will be automaticly checked, as soon as the email field is selected in backend

Autocheck via typoscript

Use typoscript to check any field like (example to check uid41 if it is an email):

plugin.tx_powermail_pi1 {
validate.uid41.auto = email
validate.uid41.errormsg = Please check your email, there is an error!
}

This autochecks are possible:

  1. email: check if value is an email

  2. url: check if value is a correct url

  3. numbers: only numbers allowed

  4. phone: numbers and / and + and - allowed

  5. alphanum: only numbers and characters allowed

Manual check via typoscript (using regulare expressions)

Use typoscript (in the setup) to check any field like (example to check uid41 if it is an url):

plugin.tx_powermail_pi1 {
validate.uid41.expression = ^(http://)?([a-z0-9-]+\.)+([a-z0-9-]{2,3})$^
validate.uid41.errormsg = Sorry, but this is not a correct URL, try again!
}

You can enter any regulare expression go check your field values

Further regex examples:

plugin.tx_powermail_pi1 {
validate.uid23.expression = /^alex\@wunschtacho\.de$/
validate.uid23.errormsg = Sorry, but this field should contain alex@wunschtacho.de!

}

plugin.tx_powermail_pi1 {
validate.uid25.expression = /^###UID26###$/
validate.uid25.errormsg = Sorry, but your password fields are different – try again!

}

Saving db values to any db table

Introduction

With powermail you can save your values to any db table (e.g. fe_users or tt_address)

Example typoscript part in setup

plugin.tx_powermail_pi1 {

# 1. tt_address entry

# allow import

dbEntry.tt_address.enable = TEXT

dbEntry.tt_address.enable.value = 1

# values from session

dbEntry.tt_address.uid41 = email

dbEntry.tt_address.uid65 = first_name

# static values from ts

dbEntryDefault.tt_address.pid = TEXT

dbEntryDefault.tt_address.pid.field = uid

dbEntryDefault.tt_address.name = TEXT

dbEntryDefault.tt_address.name.value = Alex Kellner

dbEntryDefault.tt_address.tstamp = TEXT

dbEntryDefault.tt_address.tstamp.data = date:U

# 2. fe_users entry

# values from session

dbEntry.fe_users.uid41 = email

dbEntry.fe_users.uid65 = username,name

# static values from ts

dbEntryDefault.fe_users.crdate = TEXT

dbEntryDefault.fe_users.crdate.data = date:U

}

Explanation of typoscript lines (not the comment lines) above

  1. “enable” = TEXT

  2. enable tt_address db import (default is 1) – you can disallow db import via typoscript if you want

  3. Save content of uid41 in field “email” in table “tt_address”

  4. Save content of uid65 in field “first_name” in table “tt_address”

  5. “pid” is TEXT

  6. Saves the current pid to the field “pid” in tt_address (e.g. 13)

  7. “name” is TEXT

  8. Always save “Alex Kellner” in field “name” in tt_address

  9. “tstamp” is TEXT

  10. Always save current timestamp to field “tstamp” in tt_address

  11. Save content of uid41 in field “email” in table “fe_users”

  12. Save content of uid65 in field “username” and in field “name” in table “fe_users”

  13. “crdate” is TEXT

  14. Save timestamp to field “crdate” in table “fe_users”

Some information about saving to other tables

  1. Saving is available only if table and field are existing

  2. Typoscript is available for static values (TEXT, USER, etc...)

  3. Every table contains one record

  4. dbEntryDefault is only available with dbEntry

  5. You can save your values to more fields, when you separate your fields with comma (,)

  6. With this small add to powermail, you can use powermail for many features like guestbook form, tipafriend form, fe_user registration, tt_address registration and so on...

Prefilling fields

Sequence of prefilling fields

  1. Is there a fitting piVar like &tx_powermail_pi1[uid11]=text, than use this value, and if not...

  2. Is there a value in the session, so fill field with this value, and if not...

  3. Is there a value set in the backend flexform, take this value, and if not...

  4. Should this field filled with logged in fe_user datas (set in backend), take this value, and if not...

  5. Was typoscript used to prefill a field, use this (see example below), and if not

  6. Don't fill

Example to prefill fields via typoscript setup

plugin.tx_powermail_pi1 {

prefill {

# fill field uid997 with a static text

uid997 = TEXT

uid997.value = example value

# fill field uid998 with current timestamp

uid998 = TEXT

uid998.data = date:U

# fill field uid998 with current date like "Date: 20.01.2009"

uid996 = TEXT

uid996.data = date:U

uid996.strftime = Date: %d.%m.%Y

# fill field uid995 with IP address of the user

uid995 = TEXT

uid995.data = getIndpEnv:REMOTE_ADDR

}

}

Maybe it's usefull to fill some hidden fields with hidden but important values (IP address, timestamp, Language, GET params, etc..)

Fighting spam

  1. We suggest you to use the extension wt_spamshield for fighting spam entries (see details in manual wt_spamshield)

  2. You can also use captcha (see next paragraph)

Integrate captcha to your form

  1. First of all install a captcha extension like captcha or sr_freecap

  2. Be sure, that you have chosen this extension via constants (captcha or sr_freecap)

  3. As you can add a normal textfield, you can add a captcha field, thats all

  4. If you have installed captcha AND sr_freecap, the extension use sr_freecap

  5. If you have not installed one of this extensions, an error message in frontend is shown

Example: Using captcha

Example: Using sr_freecap