Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,628 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,053 people online right now. Registration is fast and FREE... Join Now!




Required field & saving client data.

 
Reply to this topicStart new topic

Required field & saving client data., Need HTML code

jmouton
post 6 Jun, 2005 - 09:49 AM
Post #1


New D.I.C Head

*
Joined: 6 Jun, 2005
Posts: 5

I have programmed my sign up page to not allow user to continue unless they have filled in all the reuired billing information. However, when they do not it erases all the infortmation they inputed and doesnt indicate what fields are required. Can anyone provide the needed codes in HTML, for this?
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 6 Jun, 2005 - 09:52 AM
Post #2


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,846



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


How are you validating the form currently? JavaScript?

How do you want to indicate which field needs to be filled out, a prompt? highlighting the field?
User is offlineProfile CardPM

Go to the top of the page

jmouton
post 6 Jun, 2005 - 10:09 AM
Post #3


New D.I.C Head

*
Joined: 6 Jun, 2005
Posts: 5

Your going to hate me but I am new to this. I am using Yahoo Sitebuilder? I hope that answers your question? I think they use java.

A prompt would be great. In red font if possible.

Is it possible for the data they have entered to remain on the page until they correctly submit it?

Thanks Skyhawk!

Lost
Jessie
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 6 Jun, 2005 - 10:21 AM
Post #4


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


You can easily accomplish what you need using javascript (of course, this assumes your users will have javascript enalbed on their browsers, but most do). You'll write a function that runs when the form is submitted, and checks each of the manadatory fields. If the field is empty, an error message is returned. Something like the following will work:
CODE

<script language="javascript">
function validateForm()
{
  var strMessage = "Please fill in the following fields:\n";
  var strError = "";
  if(document.form1.user.value == "")
     strError += "Name\n";
  if(document.form1.password.value == "")
     strError += "Password\n";
  if(strError != "")
  {
      alert(strMessage + strError);
      return(false);
  }
  else
  {
     return(true);
  }
}
</script>

<form name="form1" action="yoururl" method="post" onSubmit="return(validateForm());">
<input type="text" name="name">
<input type="text" name="password">
<input type="submit" name="submit">
</form>

Of course, this is just a bare bones form.

SiteBuilder is actually just an interface for easy navigation of web design. not a language unto itself...HTML is a markup language, but does not perform validations per se...either a server side language (php,asp) or cleint side language (javascript) is required.
User is offlineProfile CardPM

Go to the top of the page

jmouton
post 6 Jun, 2005 - 10:45 AM
Post #5


New D.I.C Head

*
Joined: 6 Jun, 2005
Posts: 5

I think I follow you, however I am confused on where to enter text into the code you provided me. Lets say I only have one field and its called "firstname" and then a continue button which goes to step 2 in the billing process. Where would I input this data in to the code you provided?


Thankx
Jessie
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 6 Jun, 2005 - 12:19 PM
Post #6


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


You do not have to enter text in the code I provided...it is pretty much standalaone...you simply need to modify for your situation. As presented in your last post, you might use something like:
CODE

<script language="javascript">
function validateForm()
{
 var strMessage = "Please fill in the following fields:\n";
 var strError = "";
 if(document.form1.firstname.value == "")
    strError += "First Name\n";
 if(strError != "")
 {
     alert(strMessage + strError);
     return(false);
 }
 else
 {
    return(true);
 }
}
</script>

<form name="form1" action="yoururl" method="post">
<input type="text" name="firstname">
<input type="button" name="button" value="Continue" onClick="validateForm();">
</form>

Put the script between the <head> tags of your html document, the form is a representation of your own form...you can modify to fit as you like.
User is offlineProfile CardPM

Go to the top of the page

jmouton
post 6 Jun, 2005 - 01:09 PM
Post #7


New D.I.C Head

*
Joined: 6 Jun, 2005
Posts: 5

Thanks Amadeus,

I did as you said, but all it did was place a text field and continue button on the top right hand side of my page that I could not remove without deleting the code?

Could you take a look at my site and give me some advice from there?

legalresponse.net
then
sign up

please treat me like an idiot.

Thanks
Jessie
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 6 Jun, 2005 - 05:48 PM
Post #8


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


The form and text box were merely given as examples...they would be replaced by the form code that is already on your page. The form on the page in question is named form0.

Using the page you specified as an example, you would put the javascript function in the existing script tags at the top of the page. The javascript function is the one at the top of the code I provided:
CODE

function validateForm()
{
var strMessage = "Please fill in the following fields:\n";
var strError = "";
if(document.form0.FirstName.value == "")
   strError += "First Name\n";
if(strError != "")
{
    alert(strMessage + strError);
    return(false);
}
else
{
   return(true);
}
}


firstname would correspond to the input variable FirstName on the page you specified. The code given, when modified to check the new variable (FirstName instead of firstname) will ensure that something has been entered in that input box. the same process will have to be repeated for all variables that are mandatory. there are too many variables on that page for me to type out the code to, but the structure will look exactly the same as the first conditional (if) statement. If a mandatory field is not filled, put that field name in the error message. You'll notice that at the end, the function checks to see if there are any errors...if so, it displays them, and does not allow the user to submit. That is what the return value does...in the code of the form tag, which looks like this
CODE

<form name="form0" method="POST" action="http://urlmodifiedtoprotectfilesystems">

add the following
CODE

onSubmit="return(validateFunction());"

If all the mandatory fields are complete, it will allow the user to submit the form...if not, it will not allow the submit, forcing the user to fill in the missing fields.

Try it first just checking the FirstName variable...if you can get that working, you can do it all...let me know if you have any problems. And don't worry if you don't get it right away...these concepts take a little getting used to. I'm sure you'll have it in no time. Have a great night.
User is offlineProfile CardPM

Go to the top of the page

jmouton
post 8 Jun, 2005 - 11:47 AM
Post #9


New D.I.C Head

*
Joined: 6 Jun, 2005
Posts: 5

I think I got it!

Thanks Amadeus!
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 8 Jun, 2005 - 11:54 AM
Post #10


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,846



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


That's great jmouton! Welcome to dream.in.code!!! Let us know if you ever have any other questions. Hope you enjoy the site.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 03:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month