HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Coding for spotting errors in data entered
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
mightymanofexcellence



Joined: 09 Nov 2007
Posts: 2

PostPosted: Fri Nov 09, 2007 9:34 am     Coding for spotting errors in data entered Reply with quote

I am making a webpage and I am adding a section where people can post their demographics and I am wanting it to notify them with a alert when something is entered incorrectly. Can someone help me please? Is there a way to do this with javascripting?

Here is the code I have so far:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000"><SCRIPT TYPE="text/javascript">
<!--
function checkEmail(email)
{
if(email.length > 0)
{
if (email.indexOf(' ') >= 0)
alert("email addresses cannot have spaces in them");
else if (email.indexOf('@') == -1)
alert("a valid email address must have an @ in it");
}
}
//-->
</SCRIPT>


<FORM ACTION="../cgi-bin/mycgi.pl" METHOD=POST>
<p>Name </p>
<p>
<input type=TEXT name="realname" value="" size="90">
<br>
</p>
<p>&nbsp;</p>
<p>Mailing Address </p>
<p>
<input type=TEXT MAILING ADDRESS name="realname2" value="" size="90">
</p>
<p>
<input type="text" mailing="MAILING" address="ADDRESS" name="realname2" size="90" value="">
</p>
<p>
<input type="text" mailing="MAILING" address="ADDRESS" name="realname2" size="90" value="">
</p>
<p>E-Mail Address
<input type=TEXT name="realname2" size="60">
<br>
Phone Number
<input type=TEXT MAILING ADDRESS name="realname2" value="" size="20">
</p>
<p>
<input type=SUBMIT value="submit" name="SUBMIT">
</FORM>


</body>
</html>
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Fri Nov 23, 2007 5:37 pm     Reply with quote

You CAN do this with JS, but I would advise against it. You have CGI so why not use it, it would be just as easy PLUS people can't turn it off. The code would be very similar, although I can't help you on the specifics because I am not that good in CGI but use something Server-Side not Client-Side.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial