Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php |
— | — | @@ -34,6 +34,43 @@ |
35 | 35 | } |
36 | 36 | } |
37 | 37 | addEvent( window, 'load', loadPlaceholders ); |
| 38 | + |
| 39 | +function formCheck( ccform ) { |
| 40 | + var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ]; |
| 41 | + |
| 42 | + var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ], |
| 43 | + numFields = fields.length, |
| 44 | + i, |
| 45 | + output = '', |
| 46 | + currField = ''; |
| 47 | + |
| 48 | + for( i = 0; i < numFields; i++ ) { |
| 49 | + if( document.getElementById( fields[i] ).value == '' ) { |
| 50 | + currField = window['payflowproGatewayErrorMsg'+ msg[i]]; |
| 51 | + output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\\r\\n'; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + if (document.getElementById('fname').value == '$first') { |
| 56 | + output += payflowproGatewayErrorMsgJs + ' first name.\\r\\n'; |
| 57 | + } |
| 58 | + if (document.getElementById('lname').value == '$last') { |
| 59 | + output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n'; |
| 60 | + } |
| 61 | + |
| 62 | + // validate email address |
| 63 | + var apos = document.payment.emailAdd.value.indexOf("@"); |
| 64 | + var dotpos = document.payment.emailAdd.value.lastIndexOf("."); |
| 65 | + |
| 66 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 67 | + output += payflowproGatewayErrorMsgEmail; |
| 68 | + } |
| 69 | + |
| 70 | + if( output ) { |
| 71 | + alert( output ); |
| 72 | + return false; |
| 73 | + } |
| 74 | +} |
38 | 75 | </script> |
39 | 76 | EOT; |
40 | 77 | $wgOut->addHeadItem( 'placeholders', $js ); |
— | — | @@ -79,7 +116,7 @@ |
80 | 117 | |
81 | 118 | // Xml::element seems to convert html to htmlentities |
82 | 119 | $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
83 | | - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
| 120 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) ); |
84 | 121 | |
85 | 122 | $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section' ) ); |
86 | 123 | $form .= $this->generatePersonalContainer(); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php |
— | — | @@ -16,6 +16,11 @@ |
17 | 17 | |
18 | 18 | $this->loadApiJs(); // API/Ajax JS |
19 | 19 | |
| 20 | + $this->loadPlaceholders(); |
| 21 | + } |
| 22 | + |
| 23 | + public function loadPlaceholders() { |
| 24 | + global $wgOut; |
20 | 25 | // form placeholder values |
21 | 26 | $first = wfMsg( 'payflowpro_gateway-first' ); |
22 | 27 | $last = wfMsg( 'payflowpro_gateway-last' ); |
— | — | @@ -41,6 +46,43 @@ |
42 | 47 | } |
43 | 48 | } |
44 | 49 | addEvent( window, 'load', loadPlaceholders ); |
| 50 | + |
| 51 | +function formCheck( ccform ) { |
| 52 | + var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ]; |
| 53 | + |
| 54 | + var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ], |
| 55 | + numFields = fields.length, |
| 56 | + i, |
| 57 | + output = '', |
| 58 | + currField = ''; |
| 59 | + |
| 60 | + for( i = 0; i < numFields; i++ ) { |
| 61 | + if( document.getElementById( fields[i] ).value == '' ) { |
| 62 | + currField = window['payflowproGatewayErrorMsg'+ msg[i]]; |
| 63 | + output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\\r\\n'; |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + if (document.getElementById('fname').value == '$first') { |
| 68 | + output += payflowproGatewayErrorMsgJs + ' first name.\\r\\n'; |
| 69 | + } |
| 70 | + if (document.getElementById('lname').value == '$last') { |
| 71 | + output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n'; |
| 72 | + } |
| 73 | + |
| 74 | + // validate email address |
| 75 | + var apos = document.payment.emailAdd.value.indexOf("@"); |
| 76 | + var dotpos = document.payment.emailAdd.value.lastIndexOf("."); |
| 77 | + |
| 78 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 79 | + output += payflowproGatewayErrorMsgEmail; |
| 80 | + } |
| 81 | + |
| 82 | + if( output ) { |
| 83 | + alert( output ); |
| 84 | + return false; |
| 85 | + } |
| 86 | +} |
45 | 87 | </script> |
46 | 88 | EOT; |
47 | 89 | $wgOut->addHeadItem( 'placeholders', $js ); |
— | — | @@ -90,7 +132,7 @@ |
91 | 133 | |
92 | 134 | // Xml::element seems to convert html to htmlentities |
93 | 135 | $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
94 | | - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
| 136 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) ); |
95 | 137 | |
96 | 138 | $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section' ) ); |
97 | 139 | $form .= $this->generatePersonalContainer(); |
— | — | @@ -112,7 +154,7 @@ |
113 | 155 | $form .= Html::hidden( 'PaypalRedirect', false ); |
114 | 156 | $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-paypal-button' ), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit' ) ); |
115 | 157 | } else { |
116 | | - $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button' ), 'onclick' => 'submit_form( this )', 'type' => 'submit' ) ); |
| 158 | + $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button' ), 'type' => 'submit' ) ); |
117 | 159 | $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
118 | 160 | $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
119 | 161 | wfMsg( 'payflowpro_gateway-donate-click' ); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | 'payflowpro_gateway-question-comment' => 'Questions or comments? Contact: <a href="mailto:donate@wikimedia.org">donate@wikimedia.org</a>', |
100 | 100 | 'payflowpro_gateway-donate-click' => 'Your credit card will be securely processed.', |
101 | 101 | 'payflowpro_gateway-otherways' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give, including PayPal, check, or mail</a>.', |
102 | | - 'payflowpro_gateway-otherways-alt' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give</a>, including check.', |
| 102 | + 'payflowpro_gateway-otherways-alt' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give</a>, including by check.', |
103 | 103 | 'payflowpro_gateway-otherways-short' => '<a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">Other ways to give</a>', |
104 | 104 | 'payflowpro_gateway-paypal' => 'Have a PayPal account? <a href="$1/index.php/Special:PayflowProGateway?_cache_=true&paypal=true&masthead=none&form_name=$2&text_template=2010/JimmyAppealLong&language=en&utm_source=$3&utm_medium=$4&utm_campaign=$5">Donate with PayPal</a>.', |
105 | 105 | 'payflowpro_gateway-credit-storage-processing' => 'We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.', |