Forum Moderators: coopster

Message Too Old, No Replies

problem with back button

         

mysterious guy

7:42 am on Dec 23, 2004 (gmt 0)

10+ Year Member



Hi,
On submitting a form a php script is called to validate the form. I did the validation with javascript code integrated in the php script. I know its not the proper way to do the validation but...

The problem is that if I dn't fill in the form..and click on the back button..the validation script is executed and i got an error message popup.I want the validation script to be executed only when I click on the submit button.Is this possible? But still I must use the form action so that I could retrieve the values in the validation script.

A+

dreamcatcher

10:22 am on Dec 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This thread should probably be in the javascript forum.

Anyway, have you tried just using the onclick method with only the submit button?

<input type="submit" value="Submit" onclick="javascript:somefunction()">

?

mysterious guy

10:31 am on Dec 23, 2004 (gmt 0)

10+ Year Member



But how do I check whether i've fill in fields on the form.I'm using $_REQUEST to get the values when I submit the form. The validation is in a php script. I dn't think its possible to call a php script using 'OnClick'..if its possible.How?

coopster

2:14 pm on Dec 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




I want the validation script to be executed only when I click on the submit button.Is this possible?

Yes.

<form action="myscript.php" method="post"> 
<input type="submit" name="submit" value="submit" />
</form>
<?php
if (isset [php.net]($_POST['submit'])) {
// form has been submitted, validate entries
}
?>