Delivering the best Add-Ons in more than 37 languages.

中文(简体), English, हिन्दी/हिंदी, Español/Castellano, العربية, Русский язык, Français, 中文 (台灣), বাংলা, Bahasa Indonesia, اردو, Português, Deutsch, Bahasa Melayu (بهاس ملايو‎), 日本語 (にほんご), فارسی, Italiano, తెలుగు, Türkçe, ગુજરાતી, Język polski/polszczyzna, Tiếng Việt, ಕನ್ನಡ, Українська мова, ไทย
PHP Scripts / Forms

Forms and Validation

— Add-On to

Subscribe to our feed to stay up to date!

New! Follow us as you want it!

Forms and Validation - CodeCanyon Item for Sale


Ad: Bluehost hosting

Usage of “Forms and Validation”

The creation of HTML-forms is a time consuming task. Also the creation of validation rules has to be done and is always quite similar and still has to be tested intensively. The PHP class “Forms and Validation” can reduce the necessary time to create input forms on your website to a minimum. In addition there are a lot of validation rules included to make your life easier.
I created some examples to show you how easy you can use this PHP class (click on “live preview” so see them). You can try every example by your own to get an feeling for the power of the creation and validation capabilities and this class. Also you can directly see the used source code to boost your learning curve of this class functions. In the end there is a complete list of the public functions of this class.
I hope this class saves you a lot of time so you can focus on the real challenging programming tasks.


The installation of “Forms and Validation” class is very simple and saves you a lot of time. Just follow the following installation steps and you will see how easy it is to create forms and validate them.
  1. Copy the php and css file to any location of your webspace (e.g. to the directory /fav)
  2. Make sure that you can use sessions in the target file: “session_start();”
  3. Initialise the class: “require_once(‘formsAndValidation_class.php’);”
  4. You are ready to start… (best would be to start with one of the examples from the README)
  5. Adapt the css file to your need.
  6. Have fun, save a lot of time and give me a good rating on code canyon :-)


  • Super easy to integrate (include one file and you are ready to go)
  • create all html form types with one line of code
  • multiple pre-defined validations included
  • define own validations or use regular expression
  • change the css file to create a new look of the form

Public functions of the “Form and Validation”

please click on live demo to get an explanation for all functions…

Functions to define the eneral settings of the class:
  • setTarget( string $target )
  • setMethod( string $method )
  • setShowErrorsOnForm( bool )
  • setShowErrorsOnTop( bool )
  • loadVariables( array $keyAndVariables )
  • setLoadDatepicker( bool )

Functions to create the form:
  • addTextInput( string $label, string $name [, string $value = ’’, array $attributes = array(), string $addtext = ’’] )
  • addPassword( string $label, string $name [, string $value = ’’, array $attributes = array(), string $addtext = ’’] )
  • addUpload( string $label, string $name [, string $value = ’’, array $attributes = array(), string $addtext = ’’] )
  • addHiddenInput( string $label [, string $name = ’’] )
  • addTextarea( string $label, string $name [, string $value = ’’, array $attributes = array(), string $addtext = ’’, int $rows = 4, int $cols = 20] )
  • addSelectList( string $label, string $name [, array $option_list = array(), array $attributes = array()] )
  • addRadioButton( string $label, string $name [, array $option_list = array(), array $attributes = array()] )
  • addCheckboxes( string $label, string $name [, array $option_list = array(), array $attributes = array()] )
  • addDefaultValue ( string $name, string $value )
  • addCode ( string $name [, string $location = ’’] )
  • addTitle ( string $text )
  • addHeadline ( string $text )
  • addParagraph ( string $text )
  • showForm ( [ string $submit = ‘send’ ] )

Functions to validate the form:
  • save2Session ()
  • cleanSession ( [ string $formID = ‘fav’ ] )
  • isEmpty ( string $field, string $error_msg [, int $minChars = 3 ] )
  • isInteger ( string $field, string $error_msg )
  • isDecimal ( string $field, string $error_msg )
  • isWithinRange ( string $field, string $error_msg, int $min, int $max )
  • isEmailAddress ( string $field, string $error_msg )
  • isSelected ( string $field, string $error_msg )
  • isFile ( string $field, string $error_msg )
  • isFileType( string $field, string $error_msg, array $allowed_file_types )
  • isFileSizeGreaterThan( string $field, string $error_msg, int $size )
  • isFileSizeSmallerThan( string $field, string $error_msg, int $size )
  • isValidDate ( string $field, string $error_msg [, string $format = ‘mdY’, string $sep = ’/’ ] )
  • isFutureDate ( string $field, string $error_msg [, string $format = ‘mdY’, string $sep = ’/’ ] )
  • checkWithRegExpression ( string $field, string $error_msg, string $regExp )
  • checkWithOwnValidation ( array $field_names, string $error_msg, string $validation )
  • checkReload ( string $error_msg )
  • AddError ( string $error_msg )

Functions to deal with the errors:
  • isError ()
  • getErrorCount ()
  • getErrorList ()
  • showSuccess ( string $headline [, string $text = ’’] )
  • resetErrorList ()

Please help me

If you are going to rate the script less than 5 stars, please tell me what I can do to make it 5 stars for you and I will fix it. I would love to hear your suggestions on how I could improve the script, leave me a comment or send me an email and your suggestion might make it in to a future version!

Other components in this categoryAll components of this author
CommentsFrequently asked questions and answers


18 January 13

Last Update:
10 March 13

High Resolution:

Compatible Browsers:
IE6, IE7, IE8, IE9, Firefox, Safari, Opera, Chrome

Files Included:

Software Version:
PHP 5.x, PHP 5.0 - 5.2, PHP 5.3


eCommerce, eCommerce, All Items, class, contact form, form, form builder, generator, oo, php, validate, validation