vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How do i stop the loading of a page with JS? (https://vborg.vbsupport.ru/showthread.php?t=171332)

FatalBreeze 02-24-2008 12:40 PM

How do i stop the loading of a page with JS?
 
Hello!

I've built a form, and in the form there are some inputs.
So, i've built a little function in JavaScript to validate the value of the fields (in this case a radio button):

Code:


function checkShipment()
{
 if ((document.shipment.Stype[0].checked) || (document.shipment.Stype[1].checked))
  return true;
 alert("You didn't Fill The Shipment Information!");
 return false;
}

And in the HTML part:
HTML Code:

<input type="submit" value="Checkout" onclick="checkShipment()">
Now the problem is this, when the submit button is clicked, and the value of the radio button is neither one of the choices, then the alert apperas, but the new page loads, and it advances to the next page.

I want to know, how can i stop the browser from proccessing to the next page in case of errors. Thanks!

FatalBreeze 02-27-2008 08:43 AM

please someone?

Dismounted 02-27-2008 10:00 AM

Use the "onsubmit" property on the form tag and call your function with "return" (ie. onsubmit="return yourcheck(datainput)"). Return false (in your function) to stop submission, true to continue.


All times are GMT. The time now is 01:10 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01575 seconds
  • Memory Usage 1,710KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete