There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot computer connection crash css dell display driver drivers email error ethernet excel explorer firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition printer problem router slow software sound startup trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Javascript Form Validation


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
smooth's Avatar
Distinguished Member with 3,513 posts.
 
Join Date: Sep 2005
Location: NC, USA
Experience: Learning everyday :)
27-Oct-2005, 09:23 AM #1
Solved: Javascript Form Validation
Hello,

I have this in the web development forum as well, but figured I'd try it here, since it deals with some javascript.

I have a web page that has a form on it. Just before the form I have this:

Code:
<script language="javaScript">
		<!--
		function validateForm()
        {

		if document.contact.name.value = '' 
		{
		alert("Please enter your name.");
		contact.name.focus();
		return false;
		}
		else return true;

		if document.contact.email.value = ''
		{
		alert("Please enter your email address.");
		contact.email.focus();
		return false;
		}
		else return true;
		
		}
		//-->
		</script>
Now, this code is supposed to check for the value of my "name" field, and if empty alert me that it is, and put focus on that one. Does the syntax/code look right?

I implement it into the form like this:

Code:
<form name="contact" onSubmit="return validateForm()" method="post" action="forminfo.asp">
Any ideas?
__________________

Meet Your Fellow TSG Members :: Find Out What CWLMST Means :: NCAA Football :: NCAA Basketball


Looking forward to meeting you up in heaven angel

I don't care how bad I feel, when I go to work I make sure I give it my all! Never any less than 12%...

47.5% of all statistics are made up right on the spot

When something is done in ignorance, then its always best to admit that you have no excuse, fix the problem, put it behind you, and move on - valley
smooth's Avatar
Distinguished Member with 3,513 posts.
 
Join Date: Sep 2005
Location: NC, USA
Experience: Learning everyday :)
27-Oct-2005, 10:12 AM #2
Got it
Grrr, very bad syntax error on my part. I didn't put a == when I was checking for the value.

Got it working now.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:50 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.