11var FVH = {
2-
3- //------------------------------------------
4- // helper function to verify if a string
5- // is really a date
6- // uses the datepicker JQuery plugin
7- //------------------------------------------
8- isValidDate : function ( string ) {
9- try {
10- if ( string . length == 0 ) {
11- return false ;
12- }
13- $ . datepicker . parseDate ( $ ( '.hasDatepicker' ) . datepicker ( 'option' , 'dateFormat' ) , string ) ;
14- return true ;
15- } catch ( e ) {
16- return false ;
2+ //------------------------------------------
3+ // helper function to verify if a string
4+ // is really a date
5+ // uses the datepicker JQuery plugin
6+ //------------------------------------------
7+ isValidDate : function ( string ) {
8+ try {
9+ if ( string . length == 0 ) {
10+ return false ;
1711 }
18- } ,
12+ flatpickr . parseDate ( string , "Y-m-d H:i:S" ) ;
13+ return true ;
14+ } catch ( e ) {
15+ return false ;
16+ }
17+ } ,
1918
20- //------------------------------------------
21- // helper function to verify a if a string
22- // is really a time from 00:00[:00] to 23:59[:59]
23- //------------------------------------------
24- isValidTime : function ( str ) {
25- return / ^ (?: [ 0 - 1 ] \d | 2 [ 0 - 3 ] ) : [ 0 - 5 ] \d (?: : [ 0 - 5 ] \d ) ? $ / . test ( str ) ;
26- } ,
19+ //------------------------------------------
20+ // helper function to verify a if a string
21+ // is really a time from 00:00[:00] to 23:59[:59]
22+ //------------------------------------------
23+ isValidTime : function ( str ) {
24+ return / ^ (?: [ 0 - 1 ] \d | 2 [ 0 - 3 ] ) : [ 0 - 5 ] \d (?: : [ 0 - 5 ] \d ) ? $ / . test ( str ) ;
25+ } ,
2726
28- //------------------------------------------
29- // helper function to verify a if a string
30- // is really an integer
31- //------------------------------------------
32- isValidInteger : function ( str ) {
33- return / ^ \d + $ / . test ( str ) ;
34- } ,
27+ //------------------------------------------
28+ // helper function to verify a if a string
29+ // is really an integer
30+ //------------------------------------------
31+ isValidInteger : function ( str ) {
32+ return / ^ \d + $ / . test ( str ) ;
33+ } ,
3534
36- //------------------------------------------
37- // helper function to count words in a given string
38- // returns quantity of words
39- //------------------------------------------
40- countWords : function ( str ) {
41- return str . split ( / \W + / ) . length ;
42- } ,
35+ //------------------------------------------
36+ // helper function to count words in a given string
37+ // returns quantity of words
38+ //------------------------------------------
39+ countWords : function ( str ) {
40+ return str . split ( / \W + / ) . length ;
41+ } ,
4342
44- //------------------------------------------
45- // helper function to verify a if a string
46- // is really an IPV4 address
47- // uses the datapicker JQuery plugin
48- //------------------------------------------
49- isValidIPv4 : function ( ipaddress ) {
50- return / ^ ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) $ / . test ( ipaddress ) ;
51- } ,
43+ //------------------------------------------
44+ // helper function to verify a if a string
45+ // is really an IPV4 address
46+ // uses the datapicker JQuery plugin
47+ //------------------------------------------
48+ isValidIPv4 : function ( ipaddress ) {
49+ return / ^ ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ( 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) $ / . test (
50+ ipaddress
51+ ) ;
52+ } ,
5253
53- //------------------------------------------
54- // helper function to verify a if a string
55- // is really an IPV6 address
56- // uses the datapicker JQuery plugin
57- //------------------------------------------
58- isValidIPv6 : function ( ipaddress ) {
59- return / ^ ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) * : : ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) * | ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) { 7 } $ / . test ( ipaddress ) ;
60- } ,
54+ //------------------------------------------
55+ // helper function to verify a if a string
56+ // is really an IPV6 address
57+ // uses the datapicker JQuery plugin
58+ //------------------------------------------
59+ isValidIPv6 : function ( ipaddress ) {
60+ return / ^ ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) * : : ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) * | ( (?: [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) ( (?: : [ 0 - 9 A - F a - f ] { 1 , 4 } ) ) { 7 } $ / . test (
61+ ipaddress
62+ ) ;
63+ } ,
6164
62- //------------------------------------------
63- // helper function to verify a if a string
64- // is really an email address
65- // will use the input type=email if it exists (HTML5)
66- // otherwise will use a basic verification.
67- //------------------------------------------
68- isValidEmail : function ( value ) {
69- var input = document . createElement ( ' input' ) ;
65+ //------------------------------------------
66+ // helper function to verify a if a string
67+ // is really an email address
68+ // will use the input type=email if it exists (HTML5)
69+ // otherwise will use a basic verification.
70+ //------------------------------------------
71+ isValidEmail : function ( value ) {
72+ var input = document . createElement ( " input" ) ;
7073
71- input . type = ' email' ;
72- input . value = value ;
74+ input . type = " email" ;
75+ input . value = value ;
7376
74- return typeof input . checkValidity == 'function' ? input . checkValidity ( ) : / ^ \S + @ \S + \. \S + $ / . test ( value ) ;
75- } ,
77+ return typeof input . checkValidity == "function"
78+ ? input . checkValidity ( )
79+ : / ^ \S + @ \S + \. \S + $ / . test ( value ) ;
80+ } ,
7681
77- //------------------------------------------
78- // helper function to verify a if a string
79- // is really a MAC address
80- //------------------------------------------
81- isValidMacAddress : function ( sftr ) {
82- return / ^ [ \d a - f ] { 2 } ( [: -] ) (?: [ \d a - f ] { 2 } \1) { 4 } [ \d a - f ] { 2 } $ / i. test ( str ) ;
83- } ,
84- }
82+ //------------------------------------------
83+ // helper function to verify a if a string
84+ // is really a MAC address
85+ //------------------------------------------
86+ isValidMacAddress : function ( sftr ) {
87+ return / ^ [ \d a - f ] { 2 } ( [: -] ) (?: [ \d a - f ] { 2 } \1) { 4 } [ \d a - f ] { 2 } $ / i. test ( str ) ;
88+ } ,
89+ } ;
0 commit comments