Last active
December 22, 2015 12:09
-
-
Save sriannamalai/6470117 to your computer and use it in GitHub Desktop.
Code to validate Payment methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="optionForm"> | |
<select name="submitted[Which_your_registration][select]" id="edit-submitted-which-your-registration-select" class="select-or-other-select form-select required"> | |
<option selected="selected" value="">- Select -</option> | |
<option value="credit_card">Pay by credit card</option> | |
<option value="send_me_an_invoice">Send me an invoice</option> | |
<option value="select_or_other">Contact me by phone</option> | |
</select> | |
<label for="payment">Payment Method:</label> | |
<input type="radio" name="payment" id="paypal" value="paypal" /> PayPal | |
<input type="radio" name="payment" id="google" value="google" /> Google Wallet | |
<input type="radio" name="payment" id="credit" value="credit" /> Credit Card | |
<br /> | |
<input type="submit" id="edit-submit" value=" Pay Now! " /> | |
</form> | |
<script language="javascript"> | |
var $ = function (id) { | |
return document.getElementById(id); | |
} | |
$("edit-submit").onclick = checkPayment; | |
function checkPayment() { | |
var choices = $("edit-submitted-which-your-registration-select"); | |
var userChoice = choices.options[choices.selectedIndex].value; | |
if (userChoice == "") { | |
window.alert("You must select a choice!"); | |
return false; | |
} else if (userChoice == "credit_card") { | |
window.open("https://www.paypal.com/"); | |
} | |
if ($("paypal").checked) { | |
window.open("https://www.paypal.com/"); | |
} else if ($("google").checked) { | |
window.open("http://www.google.com/wallet/"); | |
} else if ($("credit").checked) { | |
window.open("https://www.authorize.net"); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment