I'm using some javascript to validate a form. It works fine in Firefox, IE10 and Chrome. Is there a way to make this below code work in Safari and IE9? When the donate button is clicked, it should be required to enter a student's name. But in Safari and IE9 the mandatory field is not being recognized, it just takes you right to paypal.
<script>
function validateForm()
{
var x=document.forms["myForm"]["os0"].value;
if (x==null || x=="")
{
alert("Please Enter the Child Your Sponsoring and Click Donate");
return false;
}
}
</script>
<form name="myForm" action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return validateForm()" method="post">
<input type="hidden" name="on0" value="Child Sponsored Name" />Please enter the student's First and Last Name Your Sponsoring and click Donate
<input type="text" maxlength="200" name="os0" required/><input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="email@website.com" /><input type="hidden" name="lc" value="US" />
<input type="hidden" name="item_name" value="5k Run Fundraiser" />
<input type="hidden" name="no_note" value="0" />
<input type="hidden" name="cn" value="ADD DONOR NAME" />
<input type="hidden" name="no_shipping" value="2" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" />
<input type="image" alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" />
<img alt="" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" border="0" />
</form>