you want php to validate your form, without ever submitting the form. How would the server side php code ever get a hold of your Request variables if you don't submit?
The only way you can call php from a page without submitting a form is to use ajax. Here is an example using jquery:
var tbVal = jQuery("#tb1").val();
jQuery.ajax({
url: "MyPage.php",
type: "POST",
data: "AjaxMethod=ValidateForm&MyData=" + tbVal,
dataType: "text",
success: function(s){
//check value of s, and handle form submission accordingly
if (s == "SUCCESS"){ /*submit form*/ }
else{ /*don't submit form*/ }
},
error: function(e){
//prevent form from submitting
}
});
you can call the above code on form submission.....
and then in your page code:
if (isset($_REQUEST["AjaxMethod"]) && $_REQUEST["AjaxMethod"] == "ValidateForm"){
//check if length is greater than three
if (strlen($_REQUEST["MyData"]) >= 3)
echo "SUCCESS";
else
echo "FAIL";
return;
}
?>
edit: sorry for the lack of indentation but yahoo answers removes the tabs and all whitespace characters in front of a line