Jump to content

form submit checking

vorticalbox
Go to solution Solved by Hazy125,

onsubmit='return check()'

I want to check if a form is submitted or not so far i have this in my header

		<script>			function check() 			{				if(confirm("Are you sure you want to redeem?")) 				{					return true;				}else 				{       					return false;				}   			}		</script>

and this is my form

echo "	<form action='include/process.php' method='POST' data-ajax='false' onsubmit='check()'>	<input  type='submit' name='leave' value='Leave'>	</form>";

so right now it pops up asking you if you want to submit but it doesn't matter what you click ok or cancel it still posts the form.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

onsubmit='return check()'

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

I would use jQuery

$('#yourform').submit(function(ev) {    /*Disable the Submit*/    ev.preventDefault();    /**    * Do your Validation Steps here     */        /* Submit the form if needed */    this.submit();});

Business Management Student @ University St. Gallen (Switzerland)

HomeServer: i7 4930k - GTX 1070ti - ASUS Rampage IV Gene - 32Gb Ram

Laptop: MacBook Pro Retina 15" 2018

Operating Systems (Virtualised using VMware): Windows Pro 10, Cent OS 7

Occupation: Software Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

 

I would use jQuery

$('#yourform').submit(function(ev) {    /*Disable the Submit*/    ev.preventDefault();    /**    * Do your Validation Steps here     */        /* Submit the form if needed */    this.submit();});

my validation in done in html5 (based form based limits) then checked in PHP before doing anything tot he database.

 

I have used a little but on jQuery so i will look into using it :)

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×