473,804 Members | 3,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About simple form validation

539 Contributor
I am a newbie on JavaScript....

I would like to know about what's wrong in my code below:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Text Example</title>
  4.     </head>
  5.  
  6.     <body>
  7.         <script language="JavaScript">
  8.             <!--
  9.                 var home="http://127.0.1:8080/start.html";
  10.  
  11.                 function redirect(){
  12.                     document.location.href=var;
  13.                 }
  14.                 function checkInput(){
  15.                     if(document.textform.textfield.value==""){
  16.                         alert("Fields not filled");
  17.                         form.textfield.focus();
  18.                         form.textfield.select();
  19.                         return false;
  20.                     }else
  21.                         return true;
  22.                 }
  23.             -->
  24.         </script>
  25.  
  26.         <form name="textform" 
  27.               method="POST" 
  28.               action="JSPActions/textAction.jsp"
  29.               onsubmit="checkInput();">
  30.  
  31.             <h3>Text Example: User login</h3><br>
  32.             Username: <input type="text" name="textfield" size=10><br>
  33.             Password: <input type="password" name="password" size=10><br><br>
  34.             <input type="submit" value="Login">
  35.         </form>
  36.     </body>
  37. </html>
Actually, i have a subject that covers basic JSP, some html and accessing database and applets.....

So, i am attempting to do it with javascript(bad input).....
On the laboratory, we didn't started yet to trap any bad/no input on the textfield

So, just to increase my appetite on web programming, i would like to validate the form using javascript( as java covers all type of Exceptions )

And i get stuck on the code above....

What's wrong with my code? It didn't invoke the checkInput method.....

Any advice? or URL that could explain it to me the effective way to validate a form?
Im looking forward to your replies experts.....
Jun 28 '08 #1
2 1379
sukatoa
539 Contributor
Ok, i have fixed it.....
Jun 28 '08 #2
acoder
16,027 Recognized Expert Moderator MVP
That's good to hear. You should also post how you solved it for the benefit of others.
Jun 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2981
by: r0adhog | last post by:
I have a very simple form: <html> <head> </head> <body> <% function ValForm() if len(document.form.newapp.all("AccessCode").Value) = 4 then document.form.newapp.submit()
9
1753
by: Coleen | last post by:
I'm using MS .Net Version 7, using VB .Net working on a "simple" web page. All I want to do is display a messagebox. I tried using Messagebox.Show, and get an error that Messagebox has not been declared. I tried using MsgBox (like we used in VB 6) but this throws application errors every time I run it I get the error "It is in valid to show a modal or form when the application is not running in UserInteractive mode. Specify the...
19
2039
by: Gérard Talbot | last post by:
posted to: alt.html and comp.infosystems.www.authoring.html followup-to: comp.infosystems.www.authoring.html Hello all, I have 2 questions about validations. 1- What's basically the difference between - validation, validity - well-formedness
16
2256
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate individual fields, such as an "Email Validation Script" or a "Phone Validation Script". Is it ok to put all these scripts on page as they are or should they be joined in some way together to be one script? I'm a total JavaScript newbie and am completely...
2
1898
by: pc | last post by:
I've created a simple form with a submit button and a textfield. I assigned a RequiredFieldValidator to the textfield and set EnabledClientScript to ture. I noticed the validator did not display the error message if the textfield was empty. It seems to me that the client side validation script did not executed. After I pressed the submit button, the validator displayed the error message. I tried entering and clearing the textfield without...
2
1206
by: ugurceng | last post by:
Hi, I have an aspx page that includes both search and insert screen , When I click the the insert button ,if required fields are blank then the validation.js throws an error, but when I click the search button , validation throws error again, how can I prevent from this problem I mean when I click the search button,validation must return true ,because search elements and insert elements are in the same form.. <form id="Form5"...
9
4184
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
2
1481
by: Cerebral Believer | last post by:
Hi folks, I am creating a site in FrontPage, and want to use PHP to validate a form I have created, however I would like the return of the users input (which the user reviews to check for errors), to be in the same design or style which the rest of my site has been created in. I have found a script wich does the basics of what I want, but it needs a lot of modifying, and I have a few questions. Here is the script: <?php
2
1825
by: runway27 | last post by:
i am helping a friend to build a forum website which uses php and mysql database. i am working on the registeration page for the forum website and its validation. i am using php 5.2.5 i am able to validate and do other tasks, however i really need help as i am stuck with regards to database injection. please answer the following questions. any help will be greatly appreciated. 1. USER NAME VALIDATION username = eregi("^+$",...
2
2229
by: Sudhakar | last post by:
A) validating username in php as part of a registration form a user fills there desired username and this is stored in a mysql. there are certain conditions for the username. a) the username should only begin either letters or numbers, and Underscore character example = user123, 123user, u_ser123, user_123 = completely case insensitive
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.