Link to home
Start Free TrialLog in
Avatar of just3082
just3082

asked on

How can I require validation in a text field using DreamWeaver MX2004

How can I require validation in a text field using DreamWeaver MX2004.

New to Dreamweaver and have started designing a form, I need the fields to have some sort of validatin requirements.

As far as that goes, I don't see a simple way to connect a Access database either.... In frontpage it was pretty simple...
Am I missing something in MX ?

Thanks,

Jamie
Avatar of webwoman
webwoman

No, not missing anything. DW has some wizards to do some of those things, but for the most part it figures you know more than it does, and know how to do what you want. FP thinks you're stupid. ;-)

What type of server, what server side scripting language? There are plenty of tutorials on those things, but you have to know what you're looking for. Same with form validation -- it's normally javascript on the client, and there are tons of pre-built scripts that you can modify.
I agree with webwoman, if you show us what fields you want to validate  and what specifications your system has (scripting language, etc) we can point you to tutorial pages or post some code.

Esopo.
Avatar of just3082

ASKER

Default ASP language is VBscript,

I have several text boxes, text1, 2, 3, etc... and Several drop down boxes DD1, DD2,etc....

That's about the size of it...

Anythingelse you need ?

just3082
You don't usually validate form fields on the server, and we need WAY more info.

Like the HTML code for the form, for a start.
Here's what I have finished so far....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Contract Synopsis</title>
<style type="text/css">
<!--
.style1 {font-family: "Times New Roman", Times, serif}
body {
      background-color: #663333;
}
.style4 {color: #FFFFFF}
.style8 {color: #FFFFFF; font-size: 18px; }
.style9 {font-family: Abbess, fantasy, cursive, "Estrangelo Edessa", Sylfaen, "Lucida Console"}
-->
</style>
</head>

<body>
<table width="710" border="1" align="center">
  <tr>
    <td colspan="4"><div align="center" class="style8">
      <p class="style9"><u><img src="../Documents%20and%20Settings/jjustice/Desktop/Graphs/logosmall.jpg" width="200" height="63"></u></p>
    </div></td>
  </tr>
  <tr>
    <td width="187"><div align="center" class="style4"><span class="style1">Requesting Department </span></div></td>
    <td width="204"><input name="RequestDepart" type="text" size="35"></td>
    <td width="65"><div align="center" class="style4">Date</div></td>
    <td width="226"><input name="textfield" type="text" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Contract With </div></td>
    <td><input name="textfield" type="text" size="35"></td>
    <td><div align="center" class="style4">Phone</div></td>
    <td><input name="textfield" type="text" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Address</div></td>
    <td><input name="textfield" type="text" size="35"></td>
    <td><div align="center" class="style4">City</div></td>
    <td><input name="textfield" type="text" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">State/Zip</div></td>
    <td><input name="textfield" type="text" size="10"> <input type="text" name="textfield"> </td>
    <td><div align="center" class="style4">C/O</div></td>
    <td><input name="textfield" type="text" size="35"></td>
  </tr>
</table>
<table width="710" border="1" align="center">
  <tr>
    <td width="699"><div align="center" class="style4"><strong>Detailed Description of Services Provided </strong></div></td>
  </tr>
  <tr>
    <td height="67"><textarea name="textfield" cols="85" rows=" " wrap="off">Please explain</textarea></td>
  </tr>
  <tr>
    <td><div align="center" class="style4"><strong>Changes From Prior Contract </strong></div></td>
  </tr>
  <tr>
    <td><textarea name="textfield" cols="85"></textarea></td>
  </tr>
</table>
<table width="710" border="1" align="center">
  <tr>
    <td width="178"><div align="center" class="style4">Type of Contract</div></td>
    <td width="217"><span class="style4">
      <select name="select" size="1">
        <option>Please Choose an Option</option>
        <option>Service Maintenance Agreement</option>
        <option>Student Program **</option>
        <option>Other</option>
      </select>
    </span></td>
    <td width="120"> <div align="center" class="style4">Status  </div></td>
    <td width="167"><span class="style4">
       <select name="select">
        <option>Please Choose an Option</option>
        <option>New</option>
        <option>Renewal</option>
      </select>
    </span> </td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Contracts From: </div></td>
    <td><input name="textfield" type="text" size="32"></td>
    <td><div align="center" class="style4">Contract To: </div></td>
    <td><input name="textfield" type="text" size="26"></td>
  </tr>
  <tr>
    <td colspan="4"><div align="center" class="style4"><strong>If an addendum, desribe in brief how it effects the present agreement: </strong></div></td>
  </tr>
  <tr>
    <td colspan="4"><textarea name="textfield" cols="85"></textarea></td>
  </tr>
</table>
  <table width="710" border="1" align="center">
    <tr>
      <td width="270"><span class="style4">Termination Period: (Days)
        <input name="textfield" type="text" size="8">
      </span></td>
      <td width="424"><div align="left"><span class="style4"> Evergreen Clause:(Auto Renewal)  
                <select name="select">
                  <option>Please Choose an Option</option>
                  <option>Yes</option>
                  <option>No</option>
                  <option>Accepted</option>
                  <option>Stricken via Addendum</option>
                </select>
      </span></div></td>
    </tr>
    <tr>
      <td colspan="2"><span class="style4">Former Contract Cost: $
        <input name="textfield" type="text" size="10">
        <select name="select">
          <option>Choose One</option>
          <option>Monthly</option>
          <option>Annually</option>
        </select>
New Contract Cost: $
<input name="textfield" type="text" size="8">
<select name="select">
  <option>Choose One</option>
  <option>Monthly</option>
  <option>Annually</option>
</select>
      </span></td>
    </tr>
  </table>
  </body>
</html>
You need form tags. And some descriptive names for the form fields wouldn't hurt. You can't name every text field 'textfield' and every select 'select'.

You really don't understand how this works, do you? No disrespect, but  DW requires that you have some understanding of how things are constructed and what's required -- again, FP thinks you're stupid and just does that for you. DW doesn't.
>You really don't understand how this works, do you? No disrespect
I ain't messing with that comment so I'm just going to play along like I didn't read that.

Dear just3082,

Seems to me you have your layout pretty much ok, but that's just the first part, now let's get the programming side going:

1. To interact with controls they must have names, if they are all called "textfield" how are you planning to give them directions?
- Give every control a particular name, to do this select it with your mouse and change the name in the first part of the properties box.

2. Are you interested in doing server side or client side validation?
Server side is not fast-interacting with the user but more reliable.
Client side can send a message as soon as the user makes a mistake.

I would personally go with a combination of the both but that's just me. Do you have ASP available in your server?

3. What type of validations do you need?
Please be specific.


Also, It wouldn't hurt to place everything after the body tag inside form tags : <form> </form>.

Best regards,

Esopo.
It sounds like you are a beginner - which is not a bad thing.  Please don't get hurt by some of the comments here that are a little out of line.

Let me try to help explain some of the basics which should help you get started.

First of all I assume that you don't really like to look at the code - and would prefer to have the program do that for you.  This is okay for simple pages - and should work in your case.

So the way you need to start if you want Dreamweaver to do a lot of the work for you like Front Page did, is open a new page in DW.

Choose Design View (rather than code view)
Choose Insert -> Form
A dotted red line should appear showing you your form.
Click inside the dotted Red Line
Choose Insert->Form Objects->Text Field

This should put a text field in your code. Clcik on it and choose Window -> Properties if it is not checked.
This should give you the properties of the textbox - including a spot to change the name (which defaults to textfield).

Make sure that you change this each time.

Repeat for other types of objects.


But if you want to just fix your current page then do this :

Go to code view.

After the <body> tag add
<form name="myform" method="post" action="mypage.asp">

and then add </form> right before the </body> tag

Then go back to design view and you should have the red dotted line around all of your form fields.  Then you can click on each one and in properties window you can change the name for each field from the default.

Once you have that done we can start working on validation and a few other clean-up things.
Thanks mrichmon... I didn't take any of the comments above personally... Hey, everyone is stupid when it comes to something... I've designed several web pages before, but always used Frontpage that did do everything for you...As a matter of fact this entire form I am working on is complete within Frontpage and works great except for the fact that the tables jump all over the screen and are hard to align... But it got the job done for the small stuff... The only reason I am leaving Frontpage is for more versatility...

In any event, I like the bottom part better (just fix your current page). I will give this a try and get back to you.

The other thing I would add besides naming each input uniquely is to also when you have a drop-down specifically list the values to be returned with each option.  The default is the value between the <option> and </option> tags, but this will make your validation harder.  I recommend adding a value to each like this :

<option value="">Choose One</option>
<option value="Monthly">Monthly</option>
<option value="Annually">Annually</option>

This way you can be sure what will be sent in as the value - you can even send something different than what is displayed.  This is useful for the "Choose One" type of options.  Since you can use "" as the value you can then do easier validation by testing for a blank selection and throwing an error in that case.
Ok, Here's the updated code...  I got the red dotted line just as you said and then renamed all of the fields to corresponding fields in my Access database.  

Now, What should I do to acually connect these fields to my database ??  Thanks, Just3082
I added a Submit button at the bottom, but it does nothing....


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Contract Synopsis</title>
<style type="text/css">
<!--
.style1 {font-family: "Times New Roman", Times, serif}
body {
      background-color: #663333;
}
.style4 {color: #FFFFFF}
.style8 {color: #FFFFFF; font-size: 18px; }
.style9 {font-family: Abbess, fantasy, cursive, "Estrangelo Edessa", Sylfaen, "Lucida Console"}
.style10 {color: #FFFF00}
.style12 {color: #FFFFFF; font-weight: bold; }
.style14 {color: #FFFFFF; font-style: italic; }
.style15 {color: #FFFF00; font-weight: bold; }
-->
</style>
</head>

<body>
<form name="contract" method="post" action="file:///G|/contract.asp">
<table width="710" border="2" align="center">
  <tr>
    <td colspan="4"><div align="center" class="style8">
      <p class="style9"><u><img src="file:///C|/Documents%20and%20Settings/jjustice/Desktop/Graphs/logosmall.jpg" width="200" height="63"></u></p>
    </div></td>
  </tr>
  <tr>
    <td width="187"><div align="center" class="style4"><span class="style1">Requesting Department </span></div></td>
    <td width="204"><input name="RequestDepartment" type="text" id="RequestDepartment" size="35"></td>
    <td width="65"><div align="center" class="style4">Date</div></td>
    <td width="226"><input name="DateofContract" type="text" id="DateofContract" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Contract With </div></td>
    <td><input name="ContractWith" type="text" id="ContractWith" size="35"></td>
    <td><div align="center" class="style4">Phone</div></td>
    <td><input name="Phone" type="text" id="Phone" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Address</div></td>
    <td><input name="Address" type="text" id="Address" size="35"></td>
    <td><div align="center" class="style4">City</div></td>
    <td><input name="City" type="text" id="City" size="35"></td>
  </tr>
  <tr>
    <td><div align="center" class="style4">State/Zip</div></td>
    <td><input name="State" type="text" id="State" size="10">
    <input name="Zip" type="text" id="Zip"> </td>
    <td><div align="center" class="style4">C/O</div></td>
    <td><input name="CO" type="text" id="CO" size="35"></td>
  </tr>
</table>
<table width="710" border="2" align="center">
  <tr>
    <td width="699"><div align="center" class="style4"><strong>Detailed Description of Services Provided </strong></div></td>
  </tr>
  <tr>
    <td height="67"><textarea name="DescriptionProvided" cols="85" rows=" " wrap="off" id="DescriptionProvided">Please explain</textarea></td>
  </tr>
  <tr>
    <td><div align="center" class="style4"><strong>Changes From Prior Contract </strong></div></td>
  </tr>
  <tr>
    <td><textarea name="ChangeinContract" cols="85" id="ChangeinContract"></textarea></td>
  </tr>
</table>
<table width="710" border="2" align="center">
  <tr>
    <td width="178"><div align="center" class="style4">Type of Contract</div></td>
    <td width="217"><span class="style4">
      <select name="TypeofContract" size="1" id="TypeofContract">
        <option>Please Choose an Option</option>
        <option>Service Maintenance Agreement</option>
        <option>Student Program **</option>
        <option>Other</option>
      </select>
    </span></td>
    <td width="120"> <div align="center" class="style4">Status  </div></td>
    <td width="167"><span class="style4">
       <select name="Status" id="Status">
        <option>Please Choose an Option</option>
        <option>New</option>
        <option>Renewal</option>
      </select>
    </span> </td>
  </tr>
  <tr>
    <td><div align="center" class="style4">Contracts From: </div></td>
    <td><input name="ContractFrom" type="text" id="ContractFrom" size="32"></td>
    <td><div align="center" class="style4">Contract To: </div></td>
    <td><input name="ContractTo" type="text" id="ContractTo" size="26"></td>
  </tr>
  <tr>
    <td colspan="4"><div align="center" class="style4"><strong>If an addendum, desribe in brief how it effects the present agreement: </strong></div></td>
  </tr>
  <tr>
    <td colspan="4"><textarea name="IfAddendum" cols="85" id="IfAddendum"></textarea></td>
  </tr>
</table>
  <table width="710" border="2" align="center">
    <tr>
      <td width="270"><span class="style4">Termination Period: (Days)
        <input name="Termination" type="text" id="Termination" size="8">
      </span></td>
      <td width="424"><div align="left"><span class="style4"> Evergreen Clause:(Auto Renewal)  
                <select name="EverGreenDropDown" id="EverGreenDropDown">
                  <option>Please Choose an Option</option>
                  <option>Yes</option>
                  <option>No</option>
                  <option>Accepted</option>
                  <option>Stricken via Addendum</option>
          </select>
      </span></div></td>
    </tr>
    <tr>
      <td colspan="2"><span class="style4">Former Contract Cost: $
        <input name="FormerContractCost" type="text" id="FormerContractCost" size="10">
        <select name="FormerDropDown" id="FormerDropDown">
          <option>Choose One</option>
          <option>Monthly</option>
          <option>Annually</option>
        </select>
New Contract Cost: $
<input name="NewContractCost" type="text" id="NewContractCost" size="8">
<select name="NewContractDropDown" id="NewContractDropDown">
  <option>Choose One</option>
  <option>Monthly</option>
  <option>Annually</option>
</select>
      </span></td>
    </tr>
  </table>
  <table width="710" border="4" align="center">
    <caption align="top">&nbsp;
    </caption>
    <tr>
      <th scope="col"><span class="style15">DOES THIS REQUIRE THE USE OF PROTECTED HEALTH INFORMATION ?    
          <select name="ProtectedHealth" id="ProtectedHealth">
          <option>Yes</option>
          <option>No</option>
        </select>
      </span></th>
    </tr>
  </table>  
  <table width="710" border="2" align="center">
    <caption align="top">&nbsp;
    </caption>
    <tr>
      <th scope="col"><span class="style4">Contract Addendum Checklist </span></th>
    </tr>
  </table>  
  <table width="710" border="2" align="center">
    <tr>
      <th width="344" scope="col"><div align="left" class="style4">
        <select name="LegalCompliance" id="LegalCompliance">
          <option>Yes</option>
          <option>No</option>
        </select>
      A. Legal Compliance </div></th>
      <th width="350" scope="col"><div align="left">
        <select name="DepartmentofHealth" id="DepartmentofHealth">
          <option>Yes</option>
          <option>No</option>
        </select>
        <span class="style4">D. Department of Health and Human Svcs</span> </div></th>
    </tr>
    <tr>
      <td><select name="Prohibition" id="Prohibition">
        <option>Yes</option>
        <option>No</option>
      </select>
        <span class="style12">B. Prohibition on Discrimination </span></td>
      <td><select name="CompliancewithJ" id="CompliancewithJ">
        <option>Yes</option>
        <option>No</option>
      </select>
        <span class="style12">E. Compliance with JCAHO</span></td>
    </tr>
    <tr>
      <td><select name="AutomaticRenewal" id="AutomaticRenewal">
        <option>Yes</option>
        <option>No</option>
      </select>
        <span class="style12">C. Automatic Renewal </span></td>
      <td><select name="Insurance" id="Insurance">
        <option>Yes</option>
        <option>No</option>
      </select>
        <span class="style12">        F. Insurance</span></td>
    </tr>
  </table>
  <table width="710" border="2" align="center">
    <tr>
      <th scope="col"><span class="style10">**If a program requiring liability insurance, a copy of the policy is required !</span></th>
    </tr>
  </table>  
  <table width="710" border="2" align="center">
    <caption align="top">&nbsp;
    </caption>
    <tr>
      <th width="364" scope="col"><div align="left" class="style4">Department Manager:
        <input name="textfield" type="text" size="30">
      </div></th>
      <th width="330" scope="col"><div align="left" class="style4">Date :
        <input name="DateDMsign" type="text" id="DateDMsign">
      </div></th>
    </tr>
    <tr>
      <td><span class="style12">Resource Manager:
      __________________________</span></td>
      <td><span class="style12">Date :
        <input name="DateRMsign" type="text" id="DateRMsign">
      </span></td>
    </tr>
    <tr>
      <td><span class="style12">Compliance Officer: __________________________</span></td>
      <td><span class="style12">Date :
        <input name="DateCOsign" type="text" id="DateCOsign">
      </span></td>
    </tr>
    <tr>
      <td colspan="2"><span class="style14">Business Associate Agreement
          <select name="IsIsNot" id="IsIsNot">
          <option>IS</option>
          <option>IS NOT</option>
        </select>
 required.     </span></td>
    </tr>
    <tr>
      <td><span class="style12">VP Finance: _________________________________</span></td>
      <td><span class="style12">Date :
        <input name="DateVPFsign" type="text" id="DateVPFsign">
      </span></td>
    </tr>
    <tr>
      <td><span class="style12">President/VP: ________________________________</span></td>
      <td><span class="style12">Date :
        <input name="PresSignDate" type="text" id="PresSignDate">
      </span></td>
    </tr>
  </table>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
  </body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the link, But I think the first thing I should work on is getting it connected to my Access database
then I can worry about the smaller stuff, such as validation..

Can someone give me some insught on connecting a form in Dreamweaver to Access ?

Thanks,

Jamie
First, confirm that the web server supports Access. Find out where the database has to go, especially if you're not in total control of the web server.

Next, you have to create the processing ASP file. That would be the contract.asp file.

And at that point, you're into another question, which should be handled separately from this one. ;-)  Your original question was on validation, not connecting to a database. You're right though -- validating the info is pretty useless if you can't do anything with it.
""""As far as that goes, I don't see a simple way to connect a Access database either.... In frontpage it was pretty simple...
Am I missing something in MX ?""""'

The above was also included in my first posting... As a matter of fact, your first posting was a direct response
""No, not missing anything. DW has some wizards to do some of those things, but for the most part it figures you know more than it does, and know how to do what you want. FP thinks you're stupid. ;-) :::


Not sure what you mean by does it support Access. I've always used IIS and have never had a problem using Access before.

I can put the database anywhere I wish...

Thanks again..

just3082

Actually, you can't put the database anywhere you want. FP handles all that for you -- this is part of the problem, you've been using a tool that automates a great deal. DW doesn't, and because of what you were using before, you don't know how things are set up.

If you're using the same server as before, you should have a folder called FPDB or something like that -- it's possible you don't see it (because, again, FP hides a LOT from you). All databases MUST go there, unless you have total access to the server and change the permissions.

You also have to set up the connection string -- again, FP would have done that, and you had no control over it and don't know how it's done.

This is the biggest problem with things like FP. Like I said, it automates a lot. Too much, if you ask me. When you move to another tool, you have a lot to learn. ;-)
On other thing... it looks like this form requires signatures. Does it? If it DOES, there's no reason to even save it in a database -- you'll need the signatures, for that you need PAPER, and if you want it to print correctly for people to sign, it's best to do it as a PDF.
It's true I've been using Frontpage for awhile, But I have designed over 12 different databases and I have always saved the databases in the folder associated with the department that I was designing the DB for and have never seen a folder named FPDB,(I am sure it exist). I do have total control over the server and can change permission's at will, however I've never had to before because the Inetpub folder is a public folder which is where my web designs are located obviously. And I have manually created each one of my connections, Frontpage didn't do it for me. True most of this I have been doing for about a year, I have a lot to learn, Which is why I am here asking for help.....:)

The form blatantly shoes that signatures are required! We also want to be able to mantain and search at will any contract that has been entered. The version I have completed in Frontpage saves the data to the DB and then prints a copy
of the contract to the users default printer to have the appropriate manager sign off. The only reason I am trying to convert everything to Dream weaver is because of the way the printout looks from Frontpage(Sucks), I redesigned the tables in Dream Weaver and they print out perfect....:)

In any event this has been going on long enough, I am going to have to search other resources because I am getting no where fast here...

Thanks for your input, It has been noted..

Just3082

You actually are getting somewhere here.

In fact we answered your original question.

If you are having trouble now with another question (i.e. connecting to an access DB using DW) then you should post that as a separate question.  The problem is you asked a whole lot of things in one question.

Really you should take the steps in order.

1) Connect to database
2) Design form
3) Validate fields
4) submit information.
You're right, I did get my original question answered, So I will close this one. I see no need in asking the other question again here.

Thanks for your assistance..

just3082