File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 3
3
* http://lab.hakim.se/ladda
4
4
* MIT licensed
5
5
*
6
- * Copyright (C) 2015 Hakim El Hattab, http://hakim.se
6
+ * Copyright (C) 2016 Hakim El Hattab, http://hakim.se
7
7
*/
8
8
/* jshint node:true, browser:true */
9
9
( function ( root , factory ) {
312
312
var form = getAncestorOfTagType ( element , 'FORM' ) ;
313
313
314
314
if ( typeof form !== 'undefined' ) {
315
+ // Modern form validation
315
316
if ( typeof form . checkValidity === 'function' ) {
316
317
valid = form . checkValidity ( ) ;
317
- } else {
318
+ }
319
+ // Fallback to manual validation for old browsers
320
+ else {
318
321
var requireds = getRequiredFields ( form ) ;
319
322
for ( var i = 0 ; i < requireds . length ; i ++ ) {
320
323
327
330
valid = false ;
328
331
}
329
332
330
- // Email field validation, otherwise button starts spinning although field is not complete
333
+ // Email field validation
331
334
if ( requireds [ i ] . type === 'email' ) {
332
335
valid = / ^ [ a - z A - Z 0 - 9 _ . + - ] + @ [ a - z A - Z 0 - 9 - ] + \. [ a - z A - Z 0 - 9 - .] + $ / . test ( requireds [ i ] . value ) ;
333
336
}
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+
6
+ < title > Ladda: Form test</ title >
7
+
8
+ < link rel ="stylesheet " href ="../css/demo.css ">
9
+ < link rel ="stylesheet " href ="../dist/ladda.min.css ">
10
+
11
+ </ head >
12
+ < body >
13
+
14
+ < article class ="examples ">
15
+
16
+ < div class ="intro ">
17
+ < h1 > Ladda From Validation</ h1 >
18
+ < p >
19
+ This page can be used to test that Ladda does NOT start spinning when submitting an invalid form.
20
+ </ p >
21
+ < form action ="">
22
+ < input type ="email " required placeholder ="Email address... " style ="font-size: 1em; padding: 14px; ">
23
+ < button type ="submit " class ="btn btn-primary ladda-button " data-color ="green " data-style ="expand-left "> < span class ="ladda-label "> Submit</ span > </ button >
24
+ </ form >
25
+ </ div >
26
+
27
+ </ article >
28
+ < script src ="../dist/spin.min.js "> </ script >
29
+ < script src ="../dist/ladda.min.js "> </ script >
30
+
31
+ < script >
32
+ Ladda . bind ( 'button[type=submit]' ) ;
33
+ </ script >
34
+
35
+ < script type ="text/javascript " src ="http://platform.twitter.com/widgets.js "> </ script >
36
+
37
+ </ body >
38
+ </ html >
You can’t perform that action at this time.
0 commit comments