moformtester - Javascript script for validation of values of input form fields.
Tested on Mozilla 1.5+, Firefox 0.8, IE 6.
moformtester - скрипт за валидиране на стойности на текстови полета във форми. Работи под Mozilla и IE.
Тествано е под Мозилла 1.5+, Firefox 0.8, IE 6.
EN
How to use:
Add an attribute validator="VALUE" to the form which has to be validated
Possible values of VALUE can be:
force - the form will not be submited until all errors in the form are cleared.
something-else-but-not-force - the errors are just marked but the form can be submitted.
Every thex fired that has to be validated against some condition has to have an attribute - movexp="CONDITION"
Every thex fired that has to be validated against some condition and you want a custom message to be displayed if that condition is not met - add an attribute movmsg="MESSAGE"
Condition format:
Conditions are described in pseudo language, where text properties can be described and tested. The condition should evaluate to true in order the field to be clear of error marks. The following arithmetic operations can be used.
Here are some operator examples:
Comparision operators:
== - equals
gt - greater than
gte - greater than or equal
lt - less than
lte - less than or equal
$ - alias for the input field value
For example :
a condition of this type $=='John Doe' - is true only if the field value is John Doe.
$.length - an alias for the length of the field /later a shorter way to describe this alias is mentioned/
"Macros" for conditions
#NUMBER - means that the value shoul be a number / can start with + or - and can contain a dot . /
movexp="#NUMBER"
#LENGTH - condtion for the length of the field
movexp="#LENGTH lt 10" - means that the condition is the length of the field to be shorter than 10 characters
#EMPTY - condition that means the field to be empty
movexp="#EMPTY"
!#EMPTY - negative to the former condition
movexp="!#EMPTY" - means that the input can not be empty
More examples:
#NUMBER && !#EMPTY - The field should be a number and not be empty
#LENGTH gte 10 - The length of the field should be more than 10 characters
БГ
Как се ползва:
На формата която трябва да бъде валидирана - трябва да се сложи атрибут validator="СТОЙНОСТ"
СТОЙНОСТ може да е:
force - значи няма да позволи изпращането на формата при неправилно попълнени полета
друго - само отбелязва неправилно попълнени полета но позволява формата да бъде изпратена
На всяко текстово поле, което трябва да бъде валидирано се поставя атрибут - movexp="ИЗРАЗ"
На всяко текстово поле, което трябва да бъде валидирано и искате да се вижда съобщение при неправилна стойност се поставя атрибут movmsg="СЪОБЩЕНИЕ"
Формат на израза:
Псевдо език, в който може да се зададат условия за валидирне, които трябва да са истина за да се валидира входа. Може да се ползват аритметични операции.
Вижте примерите, вижте и описанието:
Сравнения се правят със следните оператори
== - равно
gt - >
gte - >=;
lt - <
lte - <=;
$ - самата стойност на полето
Можете да ползвате израз примерно $=='Пепа' - истина само когато стойността е Пепа
или
$.length - дължината на полето /по нататък е описан по прост начин да се ползва дължината/
"Макроси" за по-просто описание на условията
#NUMBER - е условие което значи че трябва съдържанието да е число / може да започва с + и - и да има . /
#LENGTH - съкратено условие което е дължината на полето
#EMPTY - условие дали е празно полето
!#EMPTY - обратното на горното
Примери:
#NUMBER && !#EMPTY - Полето да е число и да не е празно
#LENGTH gte 10 - полето да не е по-късо от 10 символа
required files:
изисква:
moformtester.js
moformtester.css
works on:
работи под:
IE 6, Mozilla 1.5+
Examples:
примери: