9 Replies - 2819 Views - Last Post: 08 June 2005 - 12:54 PM Rate Topic: -----

#1 jmouton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-June 05

Required field & saving client data.

Posted 06 June 2005 - 10:49 AM

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?
Is This A Good Question/Topic? 0
  • +

Replies To: Required field & saving client data.

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,283
  • Joined: 17-March 01

Re: Required field & saving client data.

Posted 06 June 2005 - 10:52 AM

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?
Was This Post Helpful? 0
  • +
  • -

#3 jmouton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-June 05

Re: Required field & saving client data.

Posted 06 June 2005 - 11:09 AM

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
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Required field & saving client data.

Posted 06 June 2005 - 11:21 AM

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:
<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.
Was This Post Helpful? 0
  • +
  • -

#5 jmouton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-June 05

Re: Required field & saving client data.

Posted 06 June 2005 - 11:45 AM

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
Was This Post Helpful? 0
  • +
  • -

#6 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Required field & saving client data.

Posted 06 June 2005 - 01:19 PM

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:
<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.
Was This Post Helpful? 0
  • +
  • -

#7 jmouton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-June 05

Re: Required field & saving client data.

Posted 06 June 2005 - 02:09 PM

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
Was This Post Helpful? 0
  • +
  • -

#8 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Required field & saving client data.

Posted 06 June 2005 - 06:48 PM

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:
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
<form name="form0" method="POST" action="http://urlmodifiedtoprotectfilesystems">


add the following
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.
Was This Post Helpful? 0
  • +
  • -

#9 jmouton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-June 05

Re: Required field & saving client data.

Posted 08 June 2005 - 12:47 PM

I think I got it!

Thanks Amadeus!
Was This Post Helpful? 0
  • +
  • -

#10 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,283
  • Joined: 17-March 01

Re: Required field & saving client data.

Posted 08 June 2005 - 12:54 PM

That's great jmouton! Welcome to dream.in.code!!! Let us know if you ever have any other questions. Hope you enjoy the site.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1