blob: 06ffd75e6e4a674352aa5d076fbe2d74fd04a250 (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<SCRIPT TYPE="text/javascript">
function enable_quick_charge () {
//alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
if ( document.QuickChargeForm.amount.value
&& document.QuickChargeForm.pkg.value ) {
document.QuickChargeForm.submit.disabled = false;
} else {
document.QuickChargeForm.submit.disabled = true;
}
}
function enable_quick_charge_desc () {
//alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
if ( document.QuickChargeForm.amount.value ) {
document.QuickChargeForm.submit.disabled = false;
} else {
document.QuickChargeForm.submit.disabled = true;
}
}
function enable_quick_charge_amount () {
//alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
if ( document.QuickChargeForm.pkg.value ) {
document.QuickChargeForm.submit.disabled = false;
} else {
document.QuickChargeForm.submit.disabled = true;
}
}
function validate_quick_charge () {
//alert('validate_quick_charge');
var pkg = document.QuickChargeForm.pkg.value;
var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/ ;
var amount = document.QuickChargeForm.amount.value;
var amount_regex = /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ;
if ( amount_regex.test(amount) && pkg_regex.test(pkg) ) {
return true;
} else if ( amount_regex.test(amount) ) {
if ( pkg ) {
alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
} else {
alert('Enter a description for the one-time charge');
}
return false;
} else {
alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".');
return false;
}
}
</SCRIPT>
<FORM NAME="QuickChargeForm" ACTION="<%$p%>edit/process/quick-charge.cgi" METHOD="POST" onSubmit="return validate_quick_charge()">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
Description:<INPUT TYPE="text" NAME="pkg" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_desc()">
Amount:<INPUT TYPE="text" NAME="amount" SIZE=6 onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_amount()">
<% include('/elements/select-taxclass.html') %>
<INPUT NAME="submit" TYPE="submit" VALUE="One-time charge" DISABLED>
</FORM>
<%init>
my( $cust_main ) = @_;
</%init>
|