Go Back   Dreamweaver Club Forums > Graphic Design > Web Design
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 06-20-2007, 07:18 AM   #1
Join Date: Jun 2005
Location: Kolkata, India
Posts: 16
Default learning javascript - i have a question

I dont know if this is the right place to put this question but i couldnt find any other place to put it either.

So Im learning javascript from a book and the following is one of its examples.

HTML Code:
<html dir="ltr" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Date example</title>
<style type="text/css">
<script type="text/javascript">
function checkDate(){
if(!document.getElementById || !document.createTextNode){return;}
var dateField=document.getElementById('date');
var errorContainer=dateField.parentNode.getElementsByTagName('span')[0];
var checkPattern=new RegExp("\\d{2}/\\d{2}/\\d{4}");
var errorMessage='';
errorContainer.firstChild.nodeValue=' ';
var dateValue=dateField.value;
errorMessage='Please provide a date.';
} else if(!checkPattern.test(dateValue)){
errorMessage='Please provide the date in the defined format.';
return false;
return true;
<h1>Events search</h1>
<form action="eventssearch.php" method="post" onsubmit="return checkDate();">
<label for="date">Date in the format DD/MM/YYYY:</label><br />
<input type="text" id="date" name="date" />
<input type="submit" value="Check " />
<br />(example 26/04/1975) <span class="error"> </span>
The only problem is it doesnt actually give the error message. But I did find out that a small change does make the script to give the error message.
I changed the text between the span tags to &nbsp; and it started working.

But i cant figure out why that happened.
s_dragons_lair_c is offline   Reply With Quote
Old 06-20-2007, 08:29 AM   #2
davidj's Avatar
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256

thats a strange one

i use the innerHTML method which has always been good for me
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 06-21-2007, 01:10 AM   #3
Join Date: Jun 2005
Location: Kolkata, India
Posts: 16

sry but im not familiar with that method.
but im still curious to know abt my original prob.
so ur saying that it's not supposed to happen.
or maybe its because of the browsers i use. IE7 & Opera 9.21.
s_dragons_lair_c is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 06:46 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com