jquery and php form validation
I am validating a form using PHP like this (part of it):
if (!($email)){
echo "<br />
<br />
<span class=\"difftext\">Please enter your E-mail!</span>";
exit();
}
Is there a way, by using Jquery, to display the msg without refresh my page or do I have to use totally Jquery validation?
Thank you
EDIT...
('#chkout', 'submit', function(){
$.ajax({
type:开发者_运维技巧 'post',
url: 'help_scripts/prcd_chkout_ondelivery.php',
data: 'data',
success: function (){
$('#cust_order_result').html('data');
}
})
return false;
});
You can setup an AJAX call using JQuery. The AJAX call will allow you to do the server side verification without doing a page refresh.
Look up change and ajax in the JQuery manual to try to structure cod which will work for your case.
You can validate the form before it is submitted using jQuery. Just keep in mind that client-side form validation in no replacement for server-side form validation and you still need to use it too.
There are two choices: 1) Interrupt the submit process to check for values in your desired input fields using Javascript / JQuery, and allow submission when validation passes.
2) Still use PHP to do the validation, but submit the form using an AJAX call and use the PHP script to set up the cases for successful and unsuccessful validation.
The actual process will vary depending on which one of these two choices you want to use.
精彩评论