So as you may have noticed I've made a few posts recently regarding form validation and I've appreciated all the help so far. I wanted to make sure my form validated as best as possible client side before being submitted to the server.
The form data is being posted via a PHP submission that I have no control over. It's possible that some of the items may fail server side validation.
<form method="post" action="https://www.website.com/index.php" id="theform">
The form is submitted and any response from the script winds up on "https://www.website.....com/index.php" displaying on a freshly loaded webpage.
Rather than send the user to the page I want to capture the response and then display a relevant message or perform an action based on the return. So I suppose what I'm asking is how I would load that page response into a variable instead loading the page in the browser?
I literally don't even know where I want start to go about this!
I remember you now!
Well, let me see if I can help.
This time, I think you should use jQuery:
Put this script at the top of your page:
Here we go:
if ($("input:first").val() == "correct")
$('#some_where_to_place_the_alert').html('Credit Card Invalid');
jQuery works this way: (Equally to CSS)
IDs are referred with a sharp symbol -> #
Classes are referred with a dot -> .
Tags are referred without prefixes.
In this case, your form has the id of theform, so we put a sharp symbol before it: # and wrap it up with quotes, like this:
The first one is the first condition, that if succeeded it will enter the IF clause and it will execute the code and exit thanks to the return true statement. If it does not comply, it will return false, the submit will not compute and a message shall be displayed.If you can provide me with a snip of the form I can instruct you further...
I adapted this example, from:http://api.jquery.com/submit/
This is the same method Riva was telling you. If you don't like to mess with jQuery, then let me know and I'll adapt the script for you.