473,569 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="thankyo u.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 1776
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.prototyp e.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.get ElementById('tx tAddress').valu e.trim()=="") {
alert('You must specify your address');
document.getEle mentById('txtAd dress').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=Coo kieValue; expires=exp.toG MTString()";
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.prototyp e.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.get ElementById('tx tAddress').valu e.trim()=="") {
alert('You must specify your address');
document.getEle mentById('txtAd dress').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=Coo kieValue; expires=exp.toG MTString()";
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.htm l';
or
2) window.navigate ('mynewpage.htm l');

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.prototyp e.trim = stringTrim;

2. Now you can use that prototype to check your strings :
if(document.get ElementById('tx tAddress').valu e.trim()=="") {
alert('You must specify your address');
document.getEle mentById('txtAd dress').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=Coo kieValue; expires=exp.toG MTString()";
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.htm l';
Yes.
or
2) window.navigate ('mynewpage.htm l');
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.javas cript 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.htm l';

Yes.
or
2) window.navigate ('mynewpage.htm l');

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.javas cript 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.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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="thankyo u.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>Connect icut</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>Minneso ta</option><option> Mississippi</option><option> Missouri</option><option> Montana</option><option> Nebraska</option>
<option>Nevad a</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
3895
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 adresses and so on. I thought it might be a better way to programm an automated, dynamic form validation that works for all kinds of fields, shows the...
2
2137
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 example, using XPath or Java method. So is there a concept and/or standard for post-schema validation or application validation? Is there any hook in XML...
4
2600
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. How can I use both? Thank you, Tim Meagher
14
6277
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) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in...
6
2405
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
2035
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. In IE, the validation works, but no form ever gets submited. It doesn't even process the click event of the button. In mozilla, it works 100% (this...
5
3231
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 I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit...
4
2963
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 linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that...
2
4499
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. I discovered that there was no aspnet_client folder in the root of my IIS Web site, and when I ran "aspnet_regiis -c", client-side validation was...
6
3347
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 btnSubmit.Click If page.isValid then ..... end if
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.