473,386 Members | 1,706 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,386 software developers and data experts.

error checking on form

hey peoples.

I have a simple form (currently two fields) which is then passed to an ASP
page thats stores the data in a dbase

I have an error checking script which I can't get to work. the script is :
<script language="JavaScript">

<!-- Hide from older browsers...

//Function to check form is filled in correctly before submitting
function CheckForm () {

//Intialise variables
var errorMsg = "";
var errorMsgLong = "";

//Check for a name
if (document.frmregnewuser.name.value == ""){
errorMsg += "\n\tName \t\t- Enter your Name";
}

//Check for comments
if (document.frmregnewuser.e-mail.value == ""){
errorMsg += "\n\tComments \t- Enter a valid email address";
}
//If there is aproblem with the form then display an error

if ((errorMsg != "") || (errorMsgLong != "")){
msg =
"_________________________________________________ __________________\n\n";
msg += "Your registration could not be completed because there are
problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg +=
"_________________________________________________ __________________\n\n";
msg += "The following field(s) need to be corrected: -\n";

errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
return false;
}

return true;
}

// -->
</script>
I have the submit button and the following code in the form

onsubmit = "return checkform ();"

but it doesn't run the check...can anyone see anything obvious??

many thanks

Jul 20 '05 #1
2 1586
Alistair wrote:
errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);


This should be just:
alert(msg + errorMsg + "\n" + errorMsgLong);
JW

Jul 20 '05 #2
"Alistair" <news@*remove*alistairb.co.uk> writes:
I have an error checking script which I can't get to work. the script is :
A description of how it fails, best in compairison to what it should do,
would make it a *lot* easier to check.
<script language="JavaScript">
In HTML 4, the type attribute is *required*. Use
<script type="text/javascript">
It works in all browsers and is also correct.
<!-- Hide from older browsers...
Not necessary.
if (document.frmregnewuser.e-mail.value == ""){
"e-mail" is not a valid identifier. This gives the error that "mail"
is an undefined variable. Write it as:
if (document.forms['frmrengewuser'].elements['e-mail'].value == ""){

errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
As Janwillem Borleffs said, the "errorMsg +=" shouldn't be there.
but it doesn't run the check...can anyone see anything obvious??


You should enable the showing of script errors when you program.
I assueme you use IE, since you don't say anything.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marc S. Gibian | last post by:
I am putting together a Perl tool to manage a large set of tasks related to building a rather complex set of software. One of the goals for moving to Perl is to provide very rigorous error checking...
1
by: Wayne Aprato | last post by:
What can cause Access to bring up Runtime Error 2450 saying that it can't find a particular form when the form is definitely open? I am opening the form and then checking if fields are populated...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
3
by: Nathan Sokalski | last post by:
I am recieving the following error on the second postback of a page I have written: The state information is invalid for this page and might be corrupted Stack Trace: ...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.