r97008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97007‎ | r97008 | r97009 >
Date:21:48, 13 September 2011
Author:pgehres
Status:ok
Tags:
Comment:
Modifications to payflowpro validation js
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -40,6 +40,10 @@
4141 }
4242
4343 function validate_form( form ) {
 44+ if( form == null ){
 45+ form = document.payment
 46+ }
 47+
4448 var output = '';
4549 var currField = '';
4650 var i = 0;
@@ -57,20 +61,29 @@
5862 if( stateField.options[stateField.selectedIndex].value == 'YY' ) {
5963 output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\r\n';
6064 }
61 - if( countryField.options[countryField.selectedIndex].value == '' ) {
62 - output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n';
 65+ // output += "State:" + stateField.options[stateField.selectedIndex].value + '.\r\n';
 66+
 67+ if( countryField.type == "select" ){ // country is a dropdown select
 68+ if( countryField.options[countryField.selectedIndex].value == '' ) {
 69+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n';
 70+ }
 71+ // output += "Country:" + countryField.options[countryField.selectedIndex].value + '.\r\n';
6372 }
64 - output += "State:" + stateField.options[stateField.selectedIndex].value + '.\r\n';
65 - output += "Country:" + countryField.options[countryField.selectedIndex].value + '.\r\n';
 73+ else{ // country is a hidden or text input
 74+ if( countryField.value == '' ) {
 75+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n';
 76+ }
 77+ // output += "Country:" + countryField.value + '.\r\n';
 78+ }
6679
6780 //set state to "outside us"
68 - if ( document.payment.country.value != 'US' ) {
69 - document.payment.state.value = 'XX';
 81+ if ( form.country.value != 'US' ) {
 82+ form.state.value = 'XX';
7083 }
7184
7285 // validate email address
73 - var apos = document.payment.emailAdd.value.indexOf("@");
74 - var dotpos = document.payment.emailAdd.value.lastIndexOf(".");
 86+ var apos = form.emailAdd.value.indexOf("@");
 87+ var dotpos = form.emailAdd.value.lastIndexOf(".");
7588
7689 if( apos < 1 || dotpos-apos < 2 ) {
7790 output += payflowproGatewayErrorMsgEmail;

Status & tagging log