-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs4forms.js
executable file
·55 lines (46 loc) · 1.14 KB
/
js4forms.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
51
52
53
54
// js4forms.js
// Created on: Fri 2015-03-20 14:19:13 CET
// Version 0.1
var bu = false;
//console.log("put debug messages here");
// ConfirmCancel
// use: <body onbeforeunload="return ConfirmCancel()">
function ConfirmCancel() {
if(bu) {
return "Are you sure you want to leave this page?";
}
return NULL;
}
// FieldAction
// use: <input onwhatever="FieldAction()" />
function FieldAction() {
document.forms[0].submit.disabled = false;
}
// FieldChanged
// use: <input onchange="FieldChanged()" />
function FieldChanged() {
bu = true;
document.forms[0].submit.disabled = false;
}
// ResetForm
// use: <input type="reset" onclick="ResetForm()" />
function ResetForm() {
bu = false;
document.forms[0].submit.disabled = true;
}
// SubmitForm
// use: <input type="submit" value="submit" onclick="SubmitForm()" />
function SubmitForm() {
bu = false;
}
// ConfirmErase
// use: <input type="submit" value="erase" onclick="return ConfirmErase(...)" />
function ConfirmErase(content, bEnglish=true) {
var q = "Are you sure you want to delete ";
if(!bEnglish) {
q = "Es-tu sur de vouloir effacer ";
}
q += content;
q += "?";
return confirm(q);
}