forked from if-itb/IF3110-01-Simple-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfirm.js
50 lines (47 loc) · 1.32 KB
/
confirm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function confirm_delete() {
return confirm('Are you sure want to delete this post?');
}
function validateform() {
var x = document.forms["myForm"]["Tanggal"].value;
var y = document.forms["myForm"]["Judul"].value;
var z = document.forms["myForm"]["Konten"].value;
if (x == null || x == "" || y == null || y == "" || z == null || z == "") {
alert("All input must be filled out");
return false;
}
else
{
re = /^(\d{4})-(\d{1,2})-(\d{1,2})$/
if(x != '' && !x.match(re)) {
alert("Invalid date format: " + x +"\nDate must be in YYYY-MM-DD format");
return false;
}
else{
var z = new Date(x.substr(0,4),x.substr(5,2)-1,x.substr(8,2),23,59,59,0);
var y = new Date();
if(z<y){
alert("Date must be bigger than " + y);
return false;
}
}
}
}
function validateformajax() {
var x = document.getElementById("Nama");
var y = document.getElementById("Email");
var z = document.getElementById("Komentar");
if (x == null || x == "" || y == null || y == "" || z == null || z == "") {
alert("All input must be filled out");
return false;
}
else
{
re = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/
if(!y.match(re)) {
alert("Invalid email format.\nPlease insert a valid email adress");
return false;
}
else{
}
}
}