Jump to content

Prevent form from submitting


Go to solution Solved by requinix,

Recommended Posts

I'm trying to stop my form from submitting whilst it checks the login details.

<script>

	function loginbuttonFunction(){
		var tl=$("#username");
		var tp=$("#password");
			$.post('../action/logincheck.php',{user:tl.val(), password:tp.val()},function(l){
				if(l=='correct') {
						$('#loginform').submit();
					} else if(l=='locked') {
						$('#locked').show(); return false;
					} else  if(l=='incorrect') {
					 $('#incorrect').show(); return false;
				}
			});
	}

</script>

However, it's not working. It's submitting the form on any outcome.

 

I've tried using:

 $(document).ready(function() {

            $("#loginform").submit(function(e){
                e.preventDefault(e);
            });
        });

Which works on stopping the form submitting but when the details are correct it still doesn't submit the form!

Please help,

 

Thanks,

 

 

Link to comment
https://forums.phpfreaks.com/topic/294423-prevent-form-from-submitting/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.