File

  • Overview
  • Search
  • Up

Forms and Validation

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.

Integration

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 )” title=” :)” />

Features

  • 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 ()
Only registered and logged in users can download this file.
  • Author: christophdb
  • Created: 2020-10-29
  • Changed: 2020-10-27
  • Size: 180 KB
  • Views: 1,185
  • Downloads: 1
  • Price: 6 $ »» Free with active subscription
forms-and-validation-1
forms-and-validation-22