Personal tools

Form Validator

From OpenLaszlo


Introduction

This proposal calls for the client side form validation. This components will provide simple way to data validation on incoming form data, such as e-mail, dates, numbers and strings.

Demo

sample

Examples

<validatingForm>class
add each validators in this class. It dinamicaly validates when user input the values.

  <validatingForm name="myform">
    .............
    .............
    <method event="onerrorcount" args="cnt"><![CDATA[
      if(0 < cnt)
        //Error;
      else
        //Ok;
    </method>
  </validatingForm>

It's available four validators for now in the validatingForm; stringvalidator; emailvalidator; numbervalidator; datevalidator, each validators are extened from basevalidator class. basevalidator has required and requiredErrorstring attributes.

<stringvalidator>class.
Simple validation of strings, to enforce minimum and maxmun length.it has triming attribute to trim strings.
(Attributes);
minLength: OW.
maxLength: data needs shorter than this value.
trim: do trim befor validation.
minErrorstring: error message.
maxErrorstring: error messages.

  <stringvalidator required="true" minLength="5" maxLength="20" trim="true">
    <edittext name="name" />
  </stringvalidator>


<numbervalidator>class.
Simple validation for numbers to enforce minimum and maxmun value.In addtion,allow a value type, real or integer.
(Attributes);
minvalue: data need bigger than this value.
maxvalue: data need smoller than this value.
domain: real or int.
notnumberErrorstring: error message.
notintErrorstring: error message.
toobigErrorstring: error message.
toosmallErrorstring: error message.

  <numbervalidator domain="int" minvalue="-10" maxvalue="100">
    <edittext name="number" />
  </numbervalidator>


<datevalidator>class.
Provides input validation for strings treated as valid dates. It also checks the leap year day.
(Attributes);
format: set the date format(like mm/dd/yyyy).
invaliedformatErrorstring: error message.
invaliedyearErrorstring: error message.
invaliedmonthErrorstring: error message.
invalieddateErrorstring: error message.

		
  <datevalidator format="mm/dd/yyyy">
    <edittext name="birthday" />
  </datevalidator>

<emailvalidator>class.
Simple validation for standard email strings.
(Attributes);
missingatmarkErrorstring: error message.
toomanyatmarkErrorstring: error message.
missingperiodErrorstring: error message.
incorrectlydomainErrorstring: error message.

  <emailvalidator required="true">
    <edittext name="e-mail" />
  </emailvalidator>