Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 23rd, 2005, 10:59 PM
Authorized User
 
Join Date: Nov 2004
Location: spore, spore, Singapore.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanjamier Send a message via AIM to vanjamier Send a message via MSN to vanjamier Send a message via Yahoo to vanjamier
Default Javascript fdoesnt work..

Hi i did a javascript to check if the fields are empty..and if prevent submit otherwise proceed as normal.
But the javascript doesnt check anything.. i dont understand why.

Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script language="JavaScript">
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form1.name.value=="") {
themessage = themessage + " - Name";
}
if (document.form1.login.value=="") {
themessage = themessage + " -  Win2k Login ID";
}
if (document.form1.department.value=="") {
themessage = themessage + " -  Department";
}
if (document.form1.center.value=="") {
themessage = themessage + " -  center";
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
   }
}
</script>
</HEAD>
</HEAD>
<BODY>
<form name=form1 method="post" action="" enctype="multipart/form-data">
<P align=center><STRONG>Application Form For New Mobile User</STRONG></P>
<P align=left></P>
<STRONG>Please fill out the particulars:

<DIV align=center></STRONG>&nbsp;<STRONG>Personal Particulars</STRONG> <BR>
<br>Name:&nbsp;<INPUT size=14 name=name onKeyPress  ="if (event.keyCode < 65 || event.keyCode > 122) event.returnValue  = false;">&nbsp; 
Win2k Login Id: <INPUT size=15 name=login onKeyPress  ="if (event.keyCode < 65 || event.keyCode > 122) event.returnValue  = false;">&nbsp;
Login Type: <SELECT name=login>
            <option value="super">Super
            <option value="normal" selected>Normal
            <option value="Admin">Admin</option>
            </SELECT><BR><BR>
Department: <INPUT size=16 name=department onKeyPress="if (event.keyCode < 65 || event.keyCode > 122) event.returnValue  = false;">&nbsp; Cost 
Center: <INPUT size=5 name=center></DIV>
<DIV align=center>&nbsp;
</DIV>
<DIV align=center>
Remarks : <INPUT size=45 name=remarks><BR><BR></DIV>
<DIV align=center>
<TABLE cellSpacing=2 cellPadding=2 align=center>
  <TR>
    <TD><INPUT type=reset value=Reset id=reset1 name=reset1></TD>
    <TD><INPUT type=submit value=Submit name=submit onclick="verify();"></TD></TR></TABLE></DIV>
</form>
</BODY>
</HTML>
I hope someone out there can point out the mistake.
Thanks in advance
__________________
Education ruined me
Reply With Quote
  #2 (permalink)  
Old February 8th, 2005, 05:53 PM
Authorized User
 
Join Date: Nov 2003
Location: Hollywood, Fl, USA.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sonicDace Send a message via MSN to sonicDace Send a message via Yahoo to sonicDace
Default

Try changing your submit button to a normal button. That might be causing your form to submit before your function is invoked, besides, the validate function is submitting the form anyway ;)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript isnt work well on my aspx page msbsam ASP.NET 2.0 Professional 1 July 11th, 2008 08:00 AM
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
Hour Diff in javascript doen's work well gabrieldcr2 Javascript 1 April 3rd, 2008 12:47 AM
javaScript function in asp.net not work in firefox rsanuj ASP.NET 1.x and 2.0 Application Design 1 February 8th, 2007 11:37 AM



All times are GMT -4. The time now is 06:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.