I have created an HTML5 contact form as part of a check-out system on this website: http://www.organik-music.com/.
I have set it up so that a previously hidden DIV is shown when the user submits the form. This DIV contains the final payment button. Basically, I would like the purchaser to provide some information before they are able to complete their payment. Payment is being made via a third-party plugin which sends the data to PayPal, the site is a custom Wordpress installation.
In Chrome and other browsers, this DIV is only shown if the required fields are filled out. These required fields are marked with required="true". In Safari, however, it has not been working, so I appended the following to the form:
<script>
var form = document.getElementById('datacapture');
form.noValidate = true;
form.addEventListener('submit', function(event) { // listen for form submitting
if (!event.target.checkValidity()) {
event.preventDefault(); // dismiss the default functionality
alert('Please complete all required fields'); // error message
}
}, false);
</script>
While this creates a pop-up box that prompts the user to complete the form, and requires this before the data will be sent to the action php, the hidden DIV is also shown at this point regardless of whether the form has been properly completed.
The show/hide script I am using for my hidden DIV (ID "complete") is as follows:
<script>
function showHide() {
var div = document.getElementById("complete");
if (div.style.display == 'none') {
div.style.display = '';
}
else {
div.style.display = 'block';
} }
<script>
So basically I want the same functionality in Safari that I'm currently getting in Chrome etc - the hidden DIV "complete" only shows up on successful submission of the form, including all required fields. I am a little restricted in what sorts of mail form I can use as it needs to work with the plugin.
Many thanks in advance! :)