Jump to content

Prevent form from submitting


slj90

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.