1 <SCRIPT TYPE="text/javascript">
3 function enable_quick_charge () {
4 //alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
5 if ( document.QuickChargeForm.amount.value
6 && document.QuickChargeForm.pkg.value ) {
7 document.QuickChargeForm.submit.disabled = false;
9 document.QuickChargeForm.submit.disabled = true;
13 function enable_quick_charge_desc () {
14 //alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
15 if ( document.QuickChargeForm.amount.value ) {
16 document.QuickChargeForm.submit.disabled = false;
18 document.QuickChargeForm.submit.disabled = true;
22 function enable_quick_charge_amount () {
23 //alert('enable_quick_charge ' + document.QuickChargeForm.amount.value + ' - ' + document.QuickChargeForm.pkg.value );
24 if ( document.QuickChargeForm.pkg.value ) {
25 document.QuickChargeForm.submit.disabled = false;
27 document.QuickChargeForm.submit.disabled = true;
31 function validate_quick_charge () {
32 //alert('validate_quick_charge');
33 var pkg = document.QuickChargeForm.pkg.value;
34 var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/ ;
35 var amount = document.QuickChargeForm.amount.value;
36 var amount_regex = /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ;
38 if ( amount_regex.test(amount) && pkg_regex.test(pkg) ) {
40 } else if ( amount_regex.test(amount) ) {
42 alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
44 alert('Enter a description for the one-time charge');
48 alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".');
55 <FORM NAME="QuickChargeForm" ACTION="<%$p%>edit/process/quick-charge.cgi" METHOD="POST" onSubmit="return validate_quick_charge()">
57 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
59 Description:<INPUT TYPE="text" NAME="pkg" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_desc()">
61 Amount:<INPUT TYPE="text" NAME="amount" SIZE=6 onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_amount()">
63 <% include('/elements/select-taxclass.html') %>
65 <INPUT NAME="submit" TYPE="submit" VALUE="One-time charge" DISABLED>
71 my( $cust_main ) = @_;