SimpleCheck

Performs different tests on forms and highlight errors.

Usage

Works with these types of fields :

  • input (text, radio, checkbox)
  • textarea
  • select

You just need to add classes to fields you want to be checked (at least the ‘required’ class).  Avalaible test are :

  • required
  • phone
  • digit
  • minchar (2 characteres at least)
  • email

Parameters

form_idThe id of the formular.  By default it is ‘mainform’.
error_classThe class to apply to fields with error.  By default it is ‘error_f’
highlightChoose if you want to highlight errors.  0 : highlight none, 1 : highlight one, 2 : highlight all.  By default it is 1.
scroll_to_errorSmooth scroll the page to first error, by default it is set on true.

Exemple

You can initialize a formcheck by adding this in your html head this code :

<script type="text/javascript">
window.addEvent('domready', function() {
var myFormCheck = new FormCheck({
form_id : 'mainform',
error_class : 'error_f',
highlight : 2,
scroll_to_error : false
});
});
</script>

About

simplecheck.js v.1.0 for mootools v1.1 05 / 2007

by Floor SA (http://www.floor.ch) MIT-style license

Created by Luca Pillonel and David Mignot, last modified by Luca Pillonel 30.05.12

Summary
Performs different tests on forms and highlight errors.
Constructor
Internal method
Internal method
Internal method
Internal method
Internal method
Internal method
Internal method
Internal method
Internal method

Functions

initialize

initialize: function(options)

Constructor

Add event on formular and perform some stuff, you now, like settings, ...

validate

validate: function()

Internal method

Add listener on submit action and launch check process.

validateMinChar

validateMinChar: function(el)

Internal method

Check if the element value contains more than two characteres, otherwise it add it to an error array.

Parameters

elhtml element

validateDigit

validateDigit: function(el)

Internal method

Check if the element value contains only digits, otherwise it add it to an error array.

Parameters

elhtml element

validateEmail

validateEmail: function(el)

Internal method

Check if the element value is a valid email, otherwise it add it to an error array.

Parameters

elhtml element

validatePhone

validatePhone: function(el)

Internal method

Check if the element value contains a valid (more or less) phone number, otherwise it add it to an error array.

Parameters

elhtml element

validateText

validateText: function(el)

Internal method

Check if the element value contains at least something, otherwise it add it to an error array.

Parameters

elhtml element

validateSelect

validateSelect: function(el)

Internal method

Check if select is selected, otherwise it add it to an error array.

Parameters

elhtml element

validateRadio

validateRadio: function(el)

Internal method

Check if a radio box is checked, otherwise it add it to an error array.

Parameters

elhtml element

validateCheckbox

validateCheckbox: function(el)

Internal method

Check if checkbox is checked, otherwise it add it to an error array.

Parameters

elhtml element
initialize: function(options)
Constructor
validate: function()
Internal method
validateMinChar: function(el)
Internal method
validateDigit: function(el)
Internal method
validateEmail: function(el)
Internal method
validatePhone: function(el)
Internal method
validateText: function(el)
Internal method
validateSelect: function(el)
Internal method
validateRadio: function(el)
Internal method
validateCheckbox: function(el)
Internal method