Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -40,6 +40,10 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | function validate_form( form ) { |
| 44 | + if( form == null ){ |
| 45 | + form = document.payment |
| 46 | + } |
| 47 | + |
44 | 48 | var output = ''; |
45 | 49 | var currField = ''; |
46 | 50 | var i = 0; |
— | — | @@ -57,20 +61,29 @@ |
58 | 62 | if( stateField.options[stateField.selectedIndex].value == 'YY' ) { |
59 | 63 | output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\r\n'; |
60 | 64 | } |
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'; |
63 | 72 | } |
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 | + } |
66 | 79 | |
67 | 80 | //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'; |
70 | 83 | } |
71 | 84 | |
72 | 85 | // 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("."); |
75 | 88 | |
76 | 89 | if( apos < 1 || dotpos-apos < 2 ) { |
77 | 90 | output += payflowproGatewayErrorMsgEmail; |