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

Validation

I need Help!!! Please I need to write a javascript that will do the
following

Show a user name
User address
User Phone Number
City
State
zip code
telephone number
and date of Birth

I already have that part of the code done then what I have to do is add
validation so if any of these are left blank they get a message
indicating which box is left blank and point it out then I have to add
cookies so if the user information is the same it will ask take them to
antoher page telling them that their information is already there..
Here is my code so far can some one please help me with the rest.. I
really have no idea how to do this part and it is due this thirsday.

Thank you..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
</script>
<title>Web 420</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<table border="0" height="338" width="75%">
<tbody>
<tr>
<td width="56%">
<h4>Personal Information</h4>
<form name="input" action="thankyou.htm" method="get">
<pre> First Name: <input name="firstname" size="20"
type="text"><br><br><br> Last Name: <input name="lastname"
size="20"
type="text"><br><br><br> Address: <input name="address" size="20"
type="text"><br><br><br> City: <input name="city" size="20"
type="text"><br><br><br> State:
<select><option>Alabama</option><option>Alaska</option><option>Arizona</option><option>California</option><option>Colorado</option><option>Connecticut</option><option>Delaware</option><option>Florida</option><option>Georgia</option><option>Hawaii</option><option>Idaho</option><option>Illinois</option><option>Indiana</option><option>Iowa</option><option>Kansas</option><option>Kentucky</option><option>Lousisana</option><option>Maine</option><option>Maryland</option><option>Massachusetts</option><option>Michigan</option><option>Minnesota</option><option>Mississippi</option><option>Missouri</option><option>Montana</option><option>Nebraska</option><option>Nevada</option><option>New
Hampshire</option><option>New Jersey</option><option>New
Mexico</option><option>New York</option><option>North
Carolina</option><option>North
Dakota</option><option>Ohio</option><option>Oklahoma</option><option>Oregon</option><option>Pennsilvania</option><option>Rhode
Island</option><option>South Carolina</option><option>South
Dakota</option><option>Tennessee</option><option>Texas</option><option>Utah</option><option>Vermont</option><option>Virginia</option><option>Washington</option><option>West
Virginia</option><option>Wisconsin</option><option>Wyoming</option></select>
<br><br> Zip Code: <input name="zip" size="6"
type="text"><br><br><br> Telephone Number: <input
name="phone" size="11" type="text"><br><br><br> Date of Birth:
<input
name="phone" size="10" type="text"><br> <br><input value="Submit"
type="submit"><br><input name="Reset2" value="Reset"
type="reset"></pre>
&nbsp;</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>

Jul 17 '06 #1
8 1761
John,

About the client-side validations :

1.Give an ID to your input.
2.You can add a mecanism to trim spaces of the value entered by your
user
function stringTrim (s) {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
String.prototype.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.getElementById('txtAddress').value.tri m()=="") {
alert('You must specify your address');
document.getElementById('txtAddress').focus();
return false;
}

About the cookies stuff :

Do you use any server-side technology like ASP / PHP or are you using
plain HTML combined with javascript? if it is the former than you don't
need cookies in order
to check if a user is already registered. Just make the checkup
server-side in your database / xml file. It will be more robust...
remember that people can remove
their cookies anyway.

But if you don't have any server-side technology, I think you can
access cookies this way in Javascript. I saw this on newsgroups and
never tested it so
forgive me if it is wrong =) :

To write :
var exp=new Date(2010,1,1); // cookie's expiration date
document.cookie = "CookieName=CookieValue; expires=exp.toGMTString()";
To read :
just parse what is into document.cookie the way you want.

Good luck
François

john wrote:
I need Help!!! Please I need to write a javascript that will do the
following

Show a user name
User address
User Phone Number
City
State
zip code
telephone number
and date of Birth

I already have that part of the code done then what I have to do is add
validation so if any of these are left blank they get a message
indicating which box is left blank and point it out then I have to add
cookies so if the user information is the same it will ask take them to
antoher page telling them that their information is already there..
Here is my code so far can some one please help me with the rest.. I
really have no idea how to do this part and it is due this thirsday.

Thank you..
Jul 18 '06 #2
Thank you for you Help..
As far what you were talking about on the server side there is no
server. I understand what you say about the cookies but this is just
for a school project to get a grade it not going on an actual web site.
Any more help would be appreciated.. Also how do I take them to another
page to display that their information is already there??
Thank you..
John

deneb wrote:
John,

About the client-side validations :

1.Give an ID to your input.
2.You can add a mecanism to trim spaces of the value entered by your
user
function stringTrim (s) {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
String.prototype.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.getElementById('txtAddress').value.tri m()=="") {
alert('You must specify your address');
document.getElementById('txtAddress').focus();
return false;
}

About the cookies stuff :

Do you use any server-side technology like ASP / PHP or are you using
plain HTML combined with javascript? if it is the former than you don't
need cookies in order
to check if a user is already registered. Just make the checkup
server-side in your database / xml file. It will be more robust...
remember that people can remove
their cookies anyway.

But if you don't have any server-side technology, I think you can
access cookies this way in Javascript. I saw this on newsgroups and
never tested it so
forgive me if it is wrong =) :

To write :
var exp=new Date(2010,1,1); // cookie's expiration date
document.cookie = "CookieName=CookieValue; expires=exp.toGMTString()";
To read :
just parse what is into document.cookie the way you want.

Good luck
François

john wrote:
I need Help!!! Please I need to write a javascript that will do the
following

Show a user name
User address
User Phone Number
City
State
zip code
telephone number
and date of Birth

I already have that part of the code done then what I have to do is add
validation so if any of these are left blank they get a message
indicating which box is left blank and point it out then I have to add
cookies so if the user information is the same it will ask take them to
antoher page telling them that their information is already there..
Here is my code so far can some one please help me with the rest.. I
really have no idea how to do this part and it is due this thirsday.

Thank you..
Jul 19 '06 #3
Hello John,

To redirect the user to another page you can use
1) window.location='mynewpage.html';
or
2) window.navigate('mynewpage.html');

If you want a good javascript reference, you can go to that site :
http://www.devguru.com/. It may as well contains cookies
reading/writing examples.

Good luck
François

john wrote:
Thank you for you Help..
As far what you were talking about on the server side there is no
server. I understand what you say about the cookies but this is just
for a school project to get a grade it not going on an actual web site.
Any more help would be appreciated.. Also how do I take them to another
page to display that their information is already there??
Thank you..
John

deneb wrote:
John,

About the client-side validations :

1.Give an ID to your input.
2.You can add a mecanism to trim spaces of the value entered by your
user
function stringTrim (s) {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
String.prototype.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.getElementById('txtAddress').value.tri m()=="") {
alert('You must specify your address');
document.getElementById('txtAddress').focus();
return false;
}

About the cookies stuff :

Do you use any server-side technology like ASP / PHP or are you using
plain HTML combined with javascript? if it is the former than you don't
need cookies in order
to check if a user is already registered. Just make the checkup
server-side in your database / xml file. It will be more robust...
remember that people can remove
their cookies anyway.

But if you don't have any server-side technology, I think you can
access cookies this way in Javascript. I saw this on newsgroups and
never tested it so
forgive me if it is wrong =) :

To write :
var exp=new Date(2010,1,1); // cookie's expiration date
document.cookie = "CookieName=CookieValue; expires=exp.toGMTString()";
To read :
just parse what is into document.cookie the way you want.

Good luck
François

john wrote:
I need Help!!! Please I need to write a javascript that will do the
following
>
Show a user name
User address
User Phone Number
City
State
zip code
telephone number
and date of Birth
>
I already have that part of the code done then what I have to do is add
validation so if any of these are left blank they get a message
indicating which box is left blank and point it out then I have to add
cookies so if the user information is the same it will ask take them to
antoher page telling them that their information is already there..
Here is my code so far can some one please help me with the rest.. I
really have no idea how to do this part and it is due this thirsday.

Thank you..
Jul 19 '06 #4
deneb said the following on 7/19/2006 9:01 AM:
Hello John,

To redirect the user to another page you can use
1) window.location='mynewpage.html';
Yes.
or
2) window.navigate('mynewpage.html');
No.
If you want a good javascript reference, you can go to that site :
http://www.devguru.com/.
You said "good javascript reference", that is not a good one. It is not
even close. So, after you go there, go somewhere else looking for a
better one. Try the group FAQ.....
It may as well contains cookies reading/writing examples.
If its cookie code is as poor as the examples I looked at, stay away
from it.

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 19 '06 #5
Randy Webb wrote:
deneb said the following on 7/19/2006 9:01 AM:
Hello John,

To redirect the user to another page you can use
1) window.location='mynewpage.html';

Yes.
or
2) window.navigate('mynewpage.html');

No.
I didn't know that this function was depreciated, my bad.
If you want a good javascript reference, you can go to that site :
http://www.devguru.com/.

You said "good javascript reference", that is not a good one. It is not
even close. So, after you go there, go somewhere else looking for a
better one. Try the group FAQ.....
Why are you saying this? Last time I checked it was fine. There may
exists better references but devguru isn't all that bad. The group FAQ
may be a better starting point though, I didn't think about it.

Regards,
François

Jul 20 '06 #6
deneb said the following on 7/20/2006 10:12 AM:
Randy Webb wrote:
>deneb said the following on 7/19/2006 9:01 AM:
<snip>
>>If you want a good javascript reference, you can go to that site :
http://www.devguru.com/.
You said "good javascript reference", that is not a good one. It is not
even close. So, after you go there, go somewhere else looking for a
better one. Try the group FAQ.....

Why are you saying this?
Hmmm. Because it's true?
Last time I checked it was fine.
When did you check it and what is your criteria for "fine"?

Let me give you a few examples of the "fine" quality it has, fair enough?

setAttribute is known to be buggy in IE. Yet, devguru has not one
mention in the entry for setAttribute that says it is buggy in IE. What
good is a reference if it gives the false impression that something is
reliable when it isn't?

Nest. eval.

This is what devguru says about eval:

<quote>
The top-level function, eval, evaluates and/or executes a string of
JavaScript code that is contained in the codestring argument.
</quote>

First, it doesn't "evaluate and/or executes", it executes what you give
it. Plain and simple.

But, that is *all* that it says about eval. And there is no way on the
planet you can even come close to explaining eval in that one sentence.
And even then, that one sentence is patently wrong.

Shall I continue?

The site might be a basic minimum site to get a little information from,
but it is nowhere near a "good reference".
There may exists better references but devguru isn't all that bad.
There are many better references and yes, devguru, is that bad.
The group FAQ may be a better starting point though, I didn't think about it.
The FAQ for this group is a better starting point than 99.99% of the JS
sites on the web.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 20 '06 #7
JRS: In article <iN******************************@comcast.com>, dated
Thu, 20 Jul 2006 14:23:34 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>This is what devguru says about eval:

<quote>
The top-level function, eval, evaluates and/or executes a string of
JavaScript code that is contained in the codestring argument.
</quote>

First, it doesn't "evaluate and/or executes", it executes what you give
it. Plain and simple.
There's no clear distinction between the terms in English as applied to
Javascript.

If the string supplied contains an expression, with no assignment, then
"evaluates" is a perfectly good description.

If the purpose of the eval(...) is to return a quantity, i.e. the usage
is as X = eval(S) , then "evaluates" is a perfectly good
description, even if S contains assignments.

The description "evaluates" is only inappropriate if the return value of
the eval(S) is (whether or not defined) irrelevant, the code being
executed for its side effects.
Consider an input control which is given a string S such as '3+5' from
which Number 8 is required. At the ECMA-spec level, "executes" might be
appropriate; but in normal English discourse, "evaluates" would be used.
- and ISTM that a corresponding statement might well apply in "deneb"'s
native language.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 21 '06 #8
To whomever want's tp Help Me

The Program Below is what I am working with.. I need to do a cookie
redirect, so if the user has for example already enterd their name and
it is stored
in a cookie it goes to another page called Error.htm and give them a
message saying they already filled out the form.
Please I have looked this up on diffrent pages on the internet and
tried to consolidate their part with mine but I can not get it to work.

Can some one please just add to my program that is below how to do the
cookie redirect part and help me out.
please disregard the validation part I already got that piece to work..
Thank you.. I appreciate your help in advance..
I have worked on this all weekend cutting and pasting from the
internet and modifiying but I can't get it to work right.. It is not
like I am just asking for answers I have
given it 100% effort but honestly I am not good at programing and this
might be a simple task for you programers out there but it is a
nightmare for me.
Thank you

john wrote:
I need Help!!! Please I need to write a javascript that will do the
following

Show a user name
User address
User Phone Number
City
State
zip code
telephone number
and date of Birth

I already have that part of the code done then what I have to do is add
validation so if any of these are left blank they get a message
indicating which box is left blank and point it out then I have to add
cookies so if the user information is the same it will ask take them to
antoher page telling them that their information is already there..
Here is my code so far can some one please help me with the rest.. I
really have no idea how to do this part and it is due this thirsday.

Thank you..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
</script>
<title>Web 420</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<table border="0" height="338" width="75%">
<tbody>
<tr>
<td width="56%">
<h4>Personal Information</h4>
<form name="input" action="thankyou.htm" method="get">
<pre> First Name: <input name="firstname" size="20"
type="text"><br><br><br> Last Name: <input name="lastname"
size="20"
type="text"><br><br><br> Address: <input name="address" size="20"
type="text"><br><br><br> City: <input name="city" size="20"
type="text"><br><br><br> State:
<select><option>Alabama</option><option>Alaska</option><option>Arizona</option><option>California</option><option>Colorado</option>
<option>Connecticut</option><option>Delaware</option><option>Florida</option><option>Georgia</option><option>Hawaii</option>
<option>Idaho</option><option>Illinois</option><option>Indiana</option><option>Iowa</option><option>Kansas</option><option>Kentucky
</option><option>Lousisana</option><option>Maine</option><option>Maryland</option><option>Massachusetts</option><option>Michigan</option>
<option>Minnesota</option><option>Mississippi</option><option>Missouri</option><option>Montana</option><option>Nebraska</option>
<option>Nevada</option><option>New
Hampshire</option><option>New Jersey</option><option>New
Mexico</option><option>New York</option><option>North
Carolina</option><option>North
Dakota</option><option>Ohio</option><option>Oklahoma</option><option>Oregon</option><option>Pennsilvania</option><option>Rhode
Island</option><option>South Carolina</option><option>South
Dakota</option><option>Tennessee</option><option>Texas</option><option>Utah</option><option>Vermont</option><option>Virginia</option><option>Washington</option><option>West
Virginia</option><option>Wisconsin</option><option>Wyoming</option></select>
<br><br> Zip Code: <input name="zip" size="6"
type="text"><br><br><br> Telephone Number: <input
name="phone" size="11" type="text"><br><br><br> Date of Birth:
<input
name="phone" size="10" type="text"><br> <br><input value="Submit"
type="submit"><br><input name="Reset2" value="Reset"
type="reset"></pre>
&nbsp;</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>
Jul 24 '06 #9

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
2
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
6
by: Stephen | last post by:
Hi, the validation controls dont work on Netscape or Mozilla and only on Internet Explorer why? How do i correct this problem? Thanks
7
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. ...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
2
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
6
by: Jon Paal | last post by:
validation doesn't fire what's missing ????? /////// ---- code -----/////////////////////////// Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.