0

I have a sign up form in my page. So I want when the user accidentally refresh or close tab or browser and the visitor has written something in someone

<input type="text" placeholder="something"/>

then appear:

return "you have to fill the whole form";

Everything works, but I have a problem with the button! The button has no Javascript and no jQuery function. My PHP-script checks all these inputs and refresh the page. The visitor fill the whole form and click signup and appear.

return "you have to fill the whole form";

This shouldn't be like this and I cannot share the PHP code because of the security of the webpage.

Maybe can I fix this with the right JS or jQuery code!

jsFiddle Demo: http://jsfiddle.net/dV9sU/9/

PS: Sorry for my English.

rgettman
  • 176,041
  • 30
  • 275
  • 357
  • @bjb568 well this is really helpful but it is better when it dosent apear anything. Is there such a function? –  Jan 07 '14 at 22:12
  • you have set it up so that when you click on it, the alert appears. I want neither an alert or a return, I just want the page to be refreshed without something appears. You understand? –  Jan 07 '14 at 22:19
  • no it doesnt work, check this with my Fiddle link –  Jan 07 '14 at 22:32
  • i've no more code - except the php code –  Jan 07 '14 at 22:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/44743/discussion-between-selfproblemmade-and-bjb568) –  Jan 07 '14 at 22:38

1 Answers1

0

Here: http://jsfiddle.net/dV9sU/11/

<input type="submit" name="sign_in" value="Registrieren" class="success_button" onclick="alert(onbeforeunload());" />
bjb568
  • 11,089
  • 11
  • 50
  • 71