Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2003, 10:52 AM
Authorized User
 
Join Date: Sep 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp and javascript.

  function checkZip() {
    var coform = document.form2;
   if(coform.zip.value.length<=0){
      alert("Please enter a first name.");
      coform.zip.focus();
      return;
   }
}


<input type="image" onClick="javascript:checkZip();" src="submitbutton.jpg" width="84" height="28" name="image" align="top" border="0">

Hi i have this javascript code. When it pops up the messagebox, it doesnt stay on the page, but it jumps to the next page when i click the submit button. How do i make it so when the messagebox pop up, it makes the user correct the problem, before the pages submits =)

 
Old September 22nd, 2003, 11:33 AM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

try this


 function checkdata()
  {
    var blnZipOK = checkZip();
    return blnZipOK;
  }

 function checkZip() {
    var coform = document.form2;
   if(coform.zip.value.length<=0){
      alert("Please enter a first name.");
      coform.zip.focus();
      return false;
   }
   return true;
}

<form name="form1" method="post" action="myNewPage.asp" onsubmit="return checkdata();">
<input type="image" src="submitbutton.jpg" width="84" height="28" name="image" align="top" border="0">

You need to stop the form being posted if the check fails, so call the check zip from within the checkdata() function and return false if there was a problem.
where is the object named in the checkZip function?
any way the syntax would be similar in either case.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Javascript and ASP chuksted C# 5 June 16th, 2005 10:25 AM
asp/javascript Toka1 Classic ASP Basics 4 April 26th, 2004 06:13 AM
asp within javascript? vivalet Javascript How-To 2 November 14th, 2003 04:17 PM
using asp to write javascript vivalet Classic ASP Basics 3 November 6th, 2003 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.