Form field reset need help

thorjack1990

BANNED
Joined
Feb 15, 2013
Messages
71
Reaction score
9
does any1 know how to reset a form field? lets just say email add is missing when you submit the form then a pop-up appear saying "email required" when clicking ok the form and captcha will automatically reset.,any help plz?
 
If you were to do this on the client side with javascript it would be pretty simple - however, client side scripts can be circumvented and manipulated, so server side is the best but that requires that the form is submitted and processed. If you want a quick and dirty client side script, I found this on google: stackoverflow.com/questions/3279628/checking-the-form-field-values-before-submitting-that-page that does a good job showing you how to validate a form. With this method you wouldn't need to clear the captcha form for them to resubmit.
 
If you were to do this on the client side with javascript it would be pretty simple - however, client side scripts can be circumvented and manipulated, so server side is the best but that requires that the form is submitted and processed. If you want a quick and dirty client side script, I found this on google: stackoverflow.com/questions/3279628/checking-the-form-field-values-before-submitting-that-page that does a good job showing you how to validate a form. With this method you wouldn't need to clear the captcha form for them to resubmit.

how do u make a form reset? after submitting the form then i go back.,the form still has data on it.,i need to know the code to reset it when going back to prevent spammer.
 
What do you mean by "then I go back" like you submit it and then hit the back button? If that is the case then you could look at the referrer url (the page that sent you to your form). and if the referrer is your submit page then clear all the values out. If you google "javascript check referring url" you can see what I am referencing. Once again though, if they have javascript turned off then this will be pointless. If you are using PHP then you can check the referring url in the $_SERVER variable and if the isset($_SERVER['HTTP_REFERER']) and it is equal to your submit page then I would just do a header redirect to the same page to reload it which would effectively clear out all of the values in a couple lines of code. Good luck.
 
Back
Top