Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PSW_II_PARIWISATA_TRANSPORTASI
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Proyek_PSW_II_PARIWISATA
PSW_II_PARIWISATA_TRANSPORTASI
Commits
a5cadbca
Commit
a5cadbca
authored
Jun 06, 2020
by
11319009_Pratiwi Sibarani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
cfd1c36b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
0 deletions
+126
-0
validate.js
transportasi/public/vendor/php-email-form/validate.js
+126
-0
No files found.
transportasi/public/vendor/php-email-form/validate.js
0 → 100644
View file @
a5cadbca
jQuery
(
document
).
ready
(
function
(
$
)
{
"use strict"
;
//Contact
$
(
'form.php-email-form'
).
submit
(
function
()
{
var
f
=
$
(
this
).
find
(
'.form-group'
),
ferror
=
false
,
emailExp
=
/^
[^\s
()<>@,;:
\/]
+@
\w[\w\.
-
]
+
\.[
a-z
]{2,}
$/i
;
f
.
children
(
'input'
).
each
(
function
()
{
// run all inputs
var
i
=
$
(
this
);
// current input
var
rule
=
i
.
attr
(
'data-rule'
);
if
(
rule
!==
undefined
)
{
var
ierror
=
false
;
// error flag for current input
var
pos
=
rule
.
indexOf
(
':'
,
0
);
if
(
pos
>=
0
)
{
var
exp
=
rule
.
substr
(
pos
+
1
,
rule
.
length
);
rule
=
rule
.
substr
(
0
,
pos
);
}
else
{
rule
=
rule
.
substr
(
pos
+
1
,
rule
.
length
);
}
switch
(
rule
)
{
case
'required'
:
if
(
i
.
val
()
===
''
)
{
ferror
=
ierror
=
true
;
}
break
;
case
'minlen'
:
if
(
i
.
val
().
length
<
parseInt
(
exp
))
{
ferror
=
ierror
=
true
;
}
break
;
case
'email'
:
if
(
!
emailExp
.
test
(
i
.
val
()))
{
ferror
=
ierror
=
true
;
}
break
;
case
'checked'
:
if
(
!
i
.
is
(
':checked'
))
{
ferror
=
ierror
=
true
;
}
break
;
case
'regexp'
:
exp
=
new
RegExp
(
exp
);
if
(
!
exp
.
test
(
i
.
val
()))
{
ferror
=
ierror
=
true
;
}
break
;
}
i
.
next
(
'.validate'
).
html
((
ierror
?
(
i
.
attr
(
'data-msg'
)
!==
undefined
?
i
.
attr
(
'data-msg'
)
:
'wrong Input'
)
:
''
)).
show
(
'blind'
);
}
});
f
.
children
(
'textarea'
).
each
(
function
()
{
// run all inputs
var
i
=
$
(
this
);
// current input
var
rule
=
i
.
attr
(
'data-rule'
);
if
(
rule
!==
undefined
)
{
var
ierror
=
false
;
// error flag for current input
var
pos
=
rule
.
indexOf
(
':'
,
0
);
if
(
pos
>=
0
)
{
var
exp
=
rule
.
substr
(
pos
+
1
,
rule
.
length
);
rule
=
rule
.
substr
(
0
,
pos
);
}
else
{
rule
=
rule
.
substr
(
pos
+
1
,
rule
.
length
);
}
switch
(
rule
)
{
case
'required'
:
if
(
i
.
val
()
===
''
)
{
ferror
=
ierror
=
true
;
}
break
;
case
'minlen'
:
if
(
i
.
val
().
length
<
parseInt
(
exp
))
{
ferror
=
ierror
=
true
;
}
break
;
}
i
.
next
(
'.validate'
).
html
((
ierror
?
(
i
.
attr
(
'data-msg'
)
!=
undefined
?
i
.
attr
(
'data-msg'
)
:
'wrong Input'
)
:
''
)).
show
(
'blind'
);
}
});
if
(
ferror
)
return
false
;
else
var
str
=
$
(
this
).
serialize
();
var
this_form
=
$
(
this
);
var
action
=
$
(
this
).
attr
(
'action'
);
if
(
!
action
)
{
this_form
.
find
(
'.loading'
).
slideUp
();
this_form
.
find
(
'.error-message'
).
slideDown
().
html
(
'The form action property is not set!'
);
return
false
;
}
this_form
.
find
(
'.sent-message'
).
slideUp
();
this_form
.
find
(
'.error-message'
).
slideUp
();
this_form
.
find
(
'.loading'
).
slideDown
();
$
.
ajax
({
type
:
"POST"
,
url
:
action
,
data
:
str
,
success
:
function
(
msg
)
{
if
(
msg
==
'OK'
)
{
this_form
.
find
(
'.loading'
).
slideUp
();
this_form
.
find
(
'.sent-message'
).
slideDown
();
this_form
.
find
(
"input:not(input[type=submit]), textarea"
).
val
(
''
);
}
else
{
this_form
.
find
(
'.loading'
).
slideUp
();
this_form
.
find
(
'.error-message'
).
slideDown
().
html
(
msg
);
}
}
});
return
false
;
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment