Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +//<![CDATA[ |
| 3 | + |
| 4 | +function validate_form( form ) |
| 5 | +{ |
| 6 | + var msg = [ 'email address', 'first name', 'last name', 'street address', 'city', 'state', 'zip code', 'credit card number', 'the CVV from the back of your card' ]; |
| 7 | + |
| 8 | + var fields = ["email","fname","lname","street","city","state","zip","card_num","cvv"], |
| 9 | + numFields = fields.length, |
| 10 | + i, |
| 11 | + output = ''; |
| 12 | + |
| 13 | + |
| 14 | + for (i = 0; i < numFields; i++) { |
| 15 | + if (document.getElementById(fields[i]).value == "") |
| 16 | + { |
| 17 | + output += 'Please include a value for ' + msg[i] + '.\r\n'; |
| 18 | + } |
| 19 | + |
| 20 | + } |
| 21 | + |
| 22 | + // validate email address |
| 23 | + var apos=form.email.value.indexOf("@"); |
| 24 | + var dotpos=form.email.value.lastIndexOf("."); |
| 25 | + |
| 26 | + if (apos<1||dotpos-apos<2) |
| 27 | + { |
| 28 | + output += "Please include a valid email address"; |
| 29 | + } |
| 30 | + |
| 31 | + if (output) |
| 32 | + { |
| 33 | + alert(output); |
| 34 | + return false; |
| 35 | + } |
| 36 | + |
| 37 | + return true; |
| 38 | + |
| 39 | +} |
| 40 | + |
| 41 | +//]]> |
\ No newline at end of file |
Property changes on: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 42 | + native |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -14,6 +14,8 @@ |
15 | 15 | $wgParser->disableCache(); |
16 | 16 | |
17 | 17 | $this->setHeaders(); |
| 18 | + |
| 19 | + $wgOut->addHeadItem('validatescript', '<script type="text/javascript" language="javascript" src="/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>'); |
18 | 20 | |
19 | 21 | //create token if one doesn't already exist |
20 | 22 | $token = $wgUser->editToken('mrxc877668DwQQ'); |
— | — | @@ -151,13 +153,13 @@ |
152 | 154 | |
153 | 155 | //Form |
154 | 156 | $form .= XML::openElement('div', array('id' => 'mw-creditcard-form')) . |
155 | | - XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "")) . |
| 157 | + XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "", 'onsubmit' => 'return validate_form(this)')) . |
156 | 158 | XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'pfp-amount-legend' ) .$data['amount']) . |
157 | 159 | XML::hidden('amount', $data['amount']); |
158 | 160 | |
159 | 161 | $donorInput = array( |
160 | 162 | XML::inputLabel(wfMsg( 'pfp-donor-email' ), "email", "email", "30", $data['email'], array('maxlength' => "150")), |
161 | | - XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35")), |
| 163 | + XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')), |
162 | 164 | XML::inputLabel(wfMsg( 'pfp-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")), |
163 | 165 | XML::inputLabel(wfMsg( 'pfp-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")), |
164 | 166 | XML::inputLabel(wfMsg( 'pfp-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")), |
— | — | @@ -565,7 +567,7 @@ |
566 | 568 | // include response message |
567 | 569 | $transaction['response'] = $responseMsg; |
568 | 570 | // include date |
569 | | - $transaction['date'] = date('r'); |
| 571 | + $transaction['date'] = time(); |
570 | 572 | // send both the country as text and the three digit ISO code |
571 | 573 | $transaction['country_name'] = $countries[$data['country']]; |
572 | 574 | $transaction['country_code'] = $data['country']; |