プログラミング/Materialize のバックアップ差分(No.2)

更新


  • 追加された行はこの色です。
  • 削除された行はこの色です。
[[公開メモ]]

* validate の方法 [#baca2da5]

これが良いみたい?
これとか、

https://codepen.io/tdurant72/pen/vgyBjZ

これとかのようにするみたい。

http://demo.geekslabs.com/materialize-v1.0/form-validation.html

jQuery.validate はこちら。

https://jqueryvalidation.org/validate/

** Validation ルール [#i324aa63]

https://jqueryvalidation.org/documentation/#link-list-of-built-in-validation-methods

標準的なルール:

-    required – Makes the element required.
-    remote – Requests a resource to check the element for validity.
-    minlength – Makes the element require a given minimum length.
-    maxlength – Makes the element require a given maximum length.
-    rangelength – Makes the element require a given value range.
-    min – Makes the element require a given minimum.
-    max – Makes the element require a given maximum.
-    range – Makes the element require a given value range.
-    step – Makes the element require a given step.
-    email – Makes the element require a valid email
-    url – Makes the element require a valid url
-    date – Makes the element require a date.
-    dateISO – Makes the element require an ISO date.
-    number – Makes the element require a decimal number.
-    digits – Makes the element require digits only.
-    equalTo – Requires the element to be the same as another one

その他のルール:

https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/additional-methods.js

を読めば使える。

https://github.com/jquery-validation/jquery-validation/tree/master/src/additional

- accept
- additional
- alphanumeric
- bankaccountNL
- bankorgiroaccountNL
- bic
- cifES
- cpfBR
- creditcard
- creditcardtypes
- currency
- dateFA
- dateITA
- dateNL
- extension
- giroaccountNL
- greaterThan
- greaterThanEqual
- iban
- integer
- ipv4
- ipv6
- lessThan
- lessThanEqual
- lettersonly
- letterswithbasicpunc
- maxfiles
- maxsize
- maxsizetotal
- mobileNL
- mobileUK
- netmask
- nieES
- nifES
- nipPL
- notEqualTo
- nowhitespace
- pattern - 正規表現
- phoneNL
- phonePL
- phoneUK
- phoneUS
- phonesUK
- postalCodeCA
- postalcodeBR
- postalcodeIT
- postalcodeNL
- postcodeUK
- require_from_group
- skip_or_fill_minimum
- statesUS
- strippedminlength
- time
- time12h
- url2
- vinUS
- zipcodeUS
- ziprange

例えば、

 LANG:javascript
 $.validator.addMethod( "ipv4", function( value, element ) {
 	return this.optional( element ) || /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test( value );
 }, "Please enter a valid IP v4 address." );

こんな感じで独自ルールを追加できるので、とても便利だ。


Counter: 1738 (from 2010/06/03), today: 1, yesterday: 0