473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

About simple form validation

539 512MB
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 1334
sukatoa
539 512MB
Ok, i have fixed it.....
Jun 28 '08 #2
acoder
16,027 Expert Mod 8TB
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
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
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...
19
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...
16
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...
2
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...
2
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...
9
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...
2
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...
2
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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,...

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.