Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20501
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Javascript validation error |
| Date | 2013-07-01 09:11 +0200 |
| Organization | albasani.net |
| Message-ID | <kqra2n$3o3$1@news.albasani.net> (permalink) |
| References | <1f9d2bbf-3c91-4d0d-a096-11eed7897a79@googlegroups.com> |
On 2013-07-01 07:13, Manju Bishnoi wrote:
> <%@ page import="da.ma.volks.Connector" %>
> <%@page import="java.sql.*"%>
> <%@ page import="java.awt.*" %>
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> pageEncoding="ISO-8859-1"%>
This group is about JavaScript and related languages, but not about
Java. Java and JavaScript are two distinct and very different languages.
If you need assistance with JS, don't show us the JSP source. Show us
the resulting HTML that the browser receives, instead.
> var letters = /^[A-Za-z]+$/;
Both first name and last name must match this. How would a person named
"José Vianna da Motta" register?
> for( var i=0;i<document.getElementById("Registration").value.length;i++)
This loop is pointless:
- You never use the i variable after this.
- document.getElementById("Registration") gets you the <form> element,
which doesn't have a "value" property. That's the first error you get.
- Even if this would loop over all the elements, the function already
contains checks for each input field, so why the additional loop?
> if (document.Registration.fname.value == "
That's not a good way to reference form elements. Better:
var elements = document.forms.Registration.elements;
and use elements.fname, elements.lname, etc after that.
[snip many lines...]
> Here is my code, i am getting continuous alert messages without
> typing any data in the field. How can i resolve this issue. I am new to
> Java Enviornment. Please suggest me.
Every time the user enters a value and focuses the next field, ALL the
fields are checked, which will inevitably lead to an annoying JS alert.
My advice would be to let the users enter whatever they want, without
validation. Only when the user submits the form should your script check
the values.
You should also invest some time into reading up on the difference
between Java and JavaScript, and on current best practices for HTML
(i.e., don't start a new project using HTML 4.01 Transitional in 2013).
- stefan
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Javascript validation error Manju Bishnoi <manjubishnoi09@gmail.com> - 2013-06-30 22:13 -0700 Re: Javascript validation error Stefan Weiss <krewecherl@gmail.com> - 2013-07-01 09:11 +0200
csiph-web