dojo提供了几乎全方位的验证函数,在使用下面的方法之前,要通过类似下面的语句引入dojo的相关库,如
@H_404_1@
<script src="/js/dojo/dojo.js"></script> <script type="text/javas cript"> dojo.require("dojo.validate"); dojo.require("dojo.validate.check"); dojo.require("dojo.widget.Dialog"); </script>
@H_404_1@
如果不确定要引入哪些validate,可以在dojo的源文件包的src中寻找一下。
@H_404_1@
isText(value):
@H_404_1@
isText accepts a parameter,and determines if it is a string
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isInteger(value):
@H_404_1@
isInteger accepts a parameter,and determines if it is an integer. Note that this returns true is it is string integer,or a number integer.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isNumber(value):
@H_404_1@
isNumber accepts a parameter,and determines if it is a number. Note that this also returns true is it is string number.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isEmailAddress(value,allowLocal,allowCruft):
@H_404_1@
isEmailAddress determines if value is an email address,with varIoUs levels of strictness in its validation.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
allowLocal:
@H_404_1@
boolean. if true,values such as
foo@localhost will return true. allowCruft:
@H_404_1@
boolean. if true,values such as
mailto:foo@dojotoolkit.org and <
mailto:foo@dojotoolkit.org> will return true.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isEmailAddressList(value,allowCruft):
@H_404_1@
isEmailAddress determines if a list of potential values are email addresses,with varIoUs levels of strictness in its validation.
@H_404_1@
value:
@H_404_1@
comma separated list of values to test.
@H_404_1@
allowLocal:
@H_404_1@
boolean. if true,values such as
foo@localhost will return true.
@H_404_1@
allowCruft:
@H_404_1@
boolean. if true,values such as
mailto:foo@dojotoolkit.org and <
mailto:foo@dojotoolkit.org> will return true.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isValidDate(dateValue,format):
@H_404_1@
isValidate determines if a date is valid under the specified format,or a default format of MM/DD/YYYY if not is specified.
@H_404_1@
dateValue:
@H_404_1@
value to test.
@H_404_1@
format:
@H_404_1@
format to test
@H_404_1@
Accepts many format types,including ISO8601 and RFC3339. All characters in the format string are treated literally except the following tokens: YYYY - matches a 4 digit year M - matches a non zero-padded month MM - matches a zero-padded month D - matches a non zero-padded date DD - matches a zero-padded date DDD - matches an ordinal date,1-365,and 366 on leapyear ww - matches week of year,1-53 d - matches day of week,1-7
@H_404_1@
Examples: These are all equivalent to October 19,2005:
@H_404_1@
Date Format 2005-W42-3 YYYY-Www-d 2005-292 YYYY-DDD 20051019 YYYYMMDD 10/19/2005 M/D/YYYY 19.10.2005 D.M.YYYY
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
is24HourTime(value):
@H_404_1@
is24HourTime accepts a parameter,and determines if it is a valid 24 hour
@H_404_1@
time.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
is12HourTime(value):
@H_404_1@
is12HourTime accepts a parameter,and determines if it is a valid 12 hour
@H_404_1@
time.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isIpAddress(value):
@H_404_1@
isIpAddress accepts a parameter,and determines if it is a valid IP address.
@H_404_1@
(IPv6 is not currently supported)
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isUrl(value):
@H_404_1@
isUrl accepts a parameter,and determines if it is a valid url,based on
@H_404_1@
either a domain name or IP address. (IPv6 is not currently supported)
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isCurrency(value):
@H_404_1@
isCurrency accepts a parameter,and determines if it is a valid US currency.
@H_404_1@
Supports optional plus/minus sign,optional dollar-sign,optional cents,optional commas.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isPhoneNumber(value):
@H_404_1@
isPhoneNumber accepts a parameter,and determines if it is a valid US
@H_404_1@
phone number. Support 4 common separators (none,space,-,and .). Need to add support for extensions.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isSocialSecurityNumber(value):
@H_404_1@
isSocialSecurityNumber accepts a parameter,and determines if it is a valid
@H_404_1@
US Social Security Number. Supports space,or no separator.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isZipCode(value):
@H_404_1@
isZipCode accepts a parameter,and determines if it is a valid US zip code.
@H_404_1@
Supports space,or no separator between base and optional +4 portion of US zip code.
@H_404_1@
value:
@H_404_1@
value to test.
@H_404_1@
returns:
@H_404_1@
boolean
@H_404_1@
@H_404_1@
isState(value):
@H_404_1@
isState accepts a two character parameter,and determines if it is a valid
@H_404_1@
postal abbreviation for a US state or territory.
@H_404_1@
value:
@H_404_1@