Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lining up Text Boxes

Status
Not open for further replies.

kaycee79

Technical User
Jan 10, 2004
82
GB


How do I line up all the text boxes so that they are all in a straight-line with each other?

Thanks in advanced

This is the code that I want lined up

Code:
<!--#include file =&quot;clock.inc&quot;-->


<SCRIPT language=&quot;JavaScript&quot;>
<!--
function formValidateEmail(email) {
    var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
    return regex.test(email);
}
function VerifyFields() {
    var msg=&quot;The following fields appear to be invalid:&quot;;
    var blank=false;
    for(var x=0;x<document.forms[0].length;x++) {
        theObj=document.forms[0].elements[x];
        theType=theObj.type;
        theName=theObj.name;
        theValue=theObj.value;
        if((theType!=&quot;SUBMIT&quot;)&&(theType!=&quot;RESET&quot;)) {
            // check if the field is the Email address and validate
            if((theName==&quot;txtEmailAddress&quot;)&&(!formValidateEmail(theValue))) {
                msg+=&quot;\n* &quot;+theName.substring(3,theName.length);
                blank=true;
            }
            // check the other fields but ignore txtAddress2
            if((theName!=&quot;txtAddress2&quot;)&&(theValue==&quot;&quot;)) {
                msg+=&quot;\n* &quot;+theName.substring(3,theName.length);
                blank=true;
            }
        }
    }
    if(blank) {
        alert(msg);
        return false;
    }
    return true;
}
function VerifyData() {
    if (VerifyFields()) {
        if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value) {
            alert (&quot;Your passwords do not match - please reenter&quot;);
            return false;
        } else return true;
    } else return false;
}
//-->
</SCRIPT>
<div id=&quot;content&quot;>
<font face=&quot;Arial&quot;>
<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;Change Font Size&quot;>

<title>Registration Form</title>
</head>
<body style=&quot;font-family: arial&quot;>

<body bgcolor=&quot;#99CCFF&quot;>


<body onload=&quot;StartClock()&quot; onunload=&quot;KillClock()&quot;>
</font>
<form name=&quot;theClock&quot; action=&quot;adduser1.asp&quot; METHOD=&quot;post&quot; onSubmit=&quot;return VerifyData();&quot;>
    <font face=&quot;Arial&quot;>
    <input type=&quot;text&quot; name=&quot;theTime&quot; size=6><% Response.Write Date %><br>



<H1 align=&quot;center&quot;><u>Registration Form</u></H1>

    Title: <SELECT NAME=&quot;txtTitle&quot;>
		<OPTION value=&quot;mr&quot;>Mr</OPTION>
		<OPTION value=&quot;mrs&quot;>Mrs</OPTION>
		<OPTION value=&quot;miss&quot;>Miss</OPTION>
		<OPTION value=&quot;ms&quot;>Ms</OPTION>
		<OPTION value=&quot;master&quot;>Master</OPTION>
		<OPTION value=&quot;doctor&quot;>Doctor</OPTION>
		<OPTION value=&quot;lord&quot;>Lord</OPTION>
		<OPTION value=&quot;sir&quot;>Sir</OPTION>
		
	   </SELECT><BR>
    First Name: <input type=&quot;text&quot; name=&quot;txtFirstName&quot; size=&quot;20&quot; ><br>
    Surname: <input type=&quot;text&quot; name= &quot;txtSurname&quot; size=&quot;20&quot; ><br>
    Address1: <input type=&quot;text&quot; name=&quot;txtAddress1&quot; size=&quot;20&quot;><br>
    Address2: <input type=&quot;text&quot; name=&quot;txtAddress2&quot; size=&quot;20&quot;><br>
    Town: <input type=&quot;text&quot; name=&quot;txtTown&quot; size=&quot;20&quot;><br>
    County: <input type=&quot;text&quot; name=&quot;txtCounty&quot; size=&quot;20&quot; ><br>
    Post Code: <input type=&quot;text&quot; name=&quot;txtPostCode&quot; size=&quot;20&quot; ><br>
    Telephone Number: <input type=&quot;text&quot; name=&quot;txtTelephoneNo&quot; size=&quot;20&quot; ><br>
    Email Address: <input type=&quot;text&quot; name=&quot;txtEmailAddress&quot; size=&quot;20&quot; ><br>
<h3>Login Details</h3>   
    Username: <input type=&quot;text&quot; name=&quot;txtUsername&quot; size=&quot;20&quot;><br>
    Password: <input type=&quot;password&quot; name=&quot;txtPassword&quot; size=&quot;20&quot;><br>
    Verify Password: <input type=&quot;password&quot; name=&quot;txtVerifyPassword&quot; size=&quot;20&quot;><br>
    Secret Question: <input type=&quot;text&quot; name=&quot;txtSecretQuestion&quot; size=&quot;20&quot;><BR>    

    <INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;>  <INPUT TYPE=&quot;RESET&quot; VALUE=&quot;Clear&quot;>
</form>
<p>
<a href=&quot;home.asp&quot;>HOME</a> </font>
</div>
</body>
</html>
 
kaycee79:

You would have to use one of 2 methods:

a) Use a table for page layout (this method is becoming discouraged, but it still works well. :) )


Example:
<table>
<tr>
<td>First Name:</td>
<td>
<input type=&quot;text&quot; name=&quot;txtFirstName&quot; size=&quot;20&quot;>
</td>
</tr>
<!-- more table data here -->
</table>

b) Position each element with CSS ... you'll have to figure that one out though, cuz I don't wish to leave a huge post for a monday morning. :p

HTH


Greg Tammi, IT Design & Consultation
Work: Home:
 
Firstly, what's with the invalid HTML - DIV's declared in your HEAD section, multiple BODY tags?!?!?!

You might want to clean this section up first:
Code:
...
</SCRIPT>
<div id=&quot;content&quot;>
<font face=&quot;Arial&quot;>
<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;Change Font Size&quot;>

<title>Registration Form</title>
</head>
<body style=&quot;font-family: arial&quot;>

<body bgcolor=&quot;#99CCFF&quot;>


<body onload=&quot;StartClock()&quot; onunload=&quot;KillClock()&quot;>
</font>
...

I'd focus on ensuring your code is valid, before trying to line them up. [thumbsup2]

Pete.


Web Developer / Aptrix CMS (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
the code works perfectly, cant see nothing wrong with it
 
kaycee79,

If you can't see anything wrong with your code (particularly the code example section I highlighted), then (IMHO) it is no wonder you have problems with your input boxes not lining up. ;-)

Three separate body tags is clearly invalid HTML.

Regarding your textboxes, in your case, I'd use a TABLE and put each Text Label in one TD cell, and the INPUT box in a another.

Pete.


Web Developer / Aptrix CMS (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
i see what you mean, is it possible to combine them into one body tag?
 
Not only is it possible, it is needed. Also, try and look at the few tutorials on the web on how to properly write your html code. Basically, you need to learn which elements belong into the head part and which into the body part and similar basic rules. This is the common syntax:
Code:
<html>
 <head>
  <title>Doc Title</title>
  <meta tags />
  <link tags />
  <style></style>
  <script></script>
 </head>
 <body>
  all the content: divs, tables, forms etc...
 </body>
</html>
Try for good html reference and tutorials.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top