Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > question about form validation

Reply
Thread Tools

question about form validation

 
 
gerg
Guest
Posts: n/a
 
      03-13-2006
I am trying to produce a valid html / css layout at the site:

http://www.guardianharvest.com

I have a form in which I want all the form elements to be in a strait
line IE:

Username: <input box> Password: <input box> <submit button>

However apon validation it says that I can't have textual elements in a
form without a wrapper of some sort, <p> or <div> however apon adding
these elements around the text I can no longer keep all the elements in
a strait line. Check out the above site and you'll see what I mean.

Any ideas?

Thanks in advance.

Greg
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      03-13-2006
gerg wrote:

> Username: <input box> Password: <input box> <submit button>
>
> However apon validation it says that I can't have textual elements in a
> form without a wrapper of some sort, <p> or <div> however apon adding
> these elements around the text I can no longer keep all the elements in
> a strait line.


<form ...>
<div>
<label>Username: <input name="username"></label>
<label>Password: <input name="password" type="password"></label>
<input type="submit" value="Log In">
</div>
</form>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      03-13-2006
gerg <(E-Mail Removed)> wrote:

> I have a form in which I want all the form elements to be in a strait
> line IE:
>
> Username: <input box> Password: <input box> <submit button>


Stop wanting that. Such a layout reduces accessibility. Put one field,
together with its label, on one line.

> However apon validation it says that I can't have textual elements in a
> form without a wrapper of some sort, <p> or <div>


Yes, if your document purports to use syntax that requires it.

> however apon adding
> these elements around the text I can no longer keep all the elements in
> a strait line.


Yes you can. You don't put each element in a block of its own. That would
actually be against the idea of block. You can wrap all the stuff inside a
single <div> or, more reasonably, use
<div>Username: <input ...></div>
<div>Password: <input ...></div>
<div>submit button</div>

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
gerg
Guest
Posts: n/a
 
      03-13-2006
Toby Inkster wrote:
> gerg wrote:
>
>
>>Username: <input box> Password: <input box> <submit button>
>>
>>However apon validation it says that I can't have textual elements in a
>>form without a wrapper of some sort, <p> or <div> however apon adding
>>these elements around the text I can no longer keep all the elements in
>>a strait line.

>
>
> <form ...>
> <div>
> <label>Username: <input name="username"></label>
> <label>Password: <input name="password" type="password"></label>
> <input type="submit" value="Log In">
> </div>
> </form>
>


Toby, thanks for the response. After changing my markup to add the
<label> tag i'm now getting this error from the validator:

Error Line 24 column 6: document type does not allow element "label"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.

It did work as far as allowing me to keep my form in a strait line, but
the validator dosen't seem to like it.

http://www.guardianharvest.com

Thanks again Toby.

Greg
 
Reply With Quote
 
gerg
Guest
Posts: n/a
 
      03-13-2006
Jukka K. Korpela wrote:

>>I have a form in which I want all the form elements to be in a strait
>>line IE:
>>
>>Username: <input box> Password: <input box> <submit button>

>
>
> Stop wanting that. Such a layout reduces accessibility. Put one field,
> together with its label, on one line.


Thank you, that's very helpful. How does it reduce accessibility?

> Yes you can. You don't put each element in a block of its own. That would
> actually be against the idea of block. You can wrap all the stuff inside a
> single <div> or, more reasonably, use
> <div>Username: <input ...></div>
> <div>Password: <input ...></div>
> <div>submit button</div>



If I do the <div>username <input..></div> i get the stacked layout,
which is not what I WANT. Aside from "stop wanting that" is there any
other advice you could offer?

Thanks in advance.

Greg
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      03-13-2006
gerg wrote:

> It did work as far as allowing me to keep my form in a strait line, but
> the validator dosen't seem to like it.


I bet you left out the <DIV> element, which was in my example.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Carolyn Marenger
Guest
Posts: n/a
 
      03-13-2006
gerg wrote:

> Jukka K. Korpela wrote:
>
>>>I have a form in which I want all the form elements to be in a strait
>>>line IE:
>>>
>>>Username: <input box> Password: <input box> <submit button>

>>
>> Stop wanting that. Such a layout reduces accessibility. Put one field,
>> together with its label, on one line.

>
> Thank you, that's very helpful. How does it reduce accessibility?


In a narrow viewport, the forced wrapping may end up looking like...

Username: <input box> Password:[NEW LINE]
<input box> <submit button>

I think it is more of a making your site look like the rest - standards and
the like. If you prefer your look and feel - go for it!


>> Yes you can. You don't put each element in a block of its own. That would
>> actually be against the idea of block. You can wrap all the stuff inside
>> a single <div> or, more reasonably, use

>
> If I do the <div>username <input..></div> i get the stacked layout,
> which is not what I WANT. Aside from "stop wanting that" is there any
> other advice you could offer?


I haven't tried it, but <div> </div> creates a block, resulting in your
stacked layout. <span> </span> may resolve your issue. The second option
might be <div class="inline"> </div> around each item, and in your
stylesheet, specify display="inline" for the related class, to remove the
'block' effect.

> Thanks in advance.


I hope this helps,

Carolyn
--
Carolyn Marenger

 
Reply With Quote
 
gerg
Guest
Posts: n/a
 
      03-14-2006
Carolyn Marenger wrote:
> gerg wrote:
>
>
>>Jukka K. Korpela wrote:
>>
>>
>>>>I have a form in which I want all the form elements to be in a strait
>>>>line IE:
>>>>
>>>>Username: <input box> Password: <input box> <submit button>
>>>
>>>Stop wanting that. Such a layout reduces accessibility. Put one field,
>>>together with its label, on one line.

>>
>>Thank you, that's very helpful. How does it reduce accessibility?

>
>
> In a narrow viewport, the forced wrapping may end up looking like...
>
> Username: <input box> Password:[NEW LINE]
> <input box> <submit button>
>
> I think it is more of a making your site look like the rest - standards and
> the like. If you prefer your look and feel - go for it!
>
>
>
>>>Yes you can. You don't put each element in a block of its own. That would
>>>actually be against the idea of block. You can wrap all the stuff inside
>>>a single <div> or, more reasonably, use

>>
>>If I do the <div>username <input..></div> i get the stacked layout,
>>which is not what I WANT. Aside from "stop wanting that" is there any
>>other advice you could offer?

>
>
> I haven't tried it, but <div> </div> creates a block, resulting in your
> stacked layout. <span> </span> may resolve your issue. The second option
> might be <div class="inline"> </div> around each item, and in your
> stylesheet, specify display="inline" for the related class, to remove the
> 'block' effect.
>
>
>>Thanks in advance.

>
>
> I hope this helps,
>
> Carolyn



Carolyn and Toby, Thank you for your quick and consise responses. I'm
gonna go make this work now! Thanks again.

Greg
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      03-14-2006
gerg <(E-Mail Removed)> wrote:

> Aside from "stop wanting that" is there any
> other advice you could offer?


I did, since I expected that you'll refuse to accept the good advice.
The second best advice was in my message, and you even quoted it.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A form validation library with javascript validation Grigory Temchenko Python 0 12-28-2008 08:38 PM
string validation/ form validation OriginalBrownster Python 1 08-21-2006 01:50 AM
Struts validation for combine form fields validation Sumith Mathur Java 0 09-23-2004 06:26 PM
Form Validation Problem...Persisiting form fields on validation failure. bnp Javascript 4 05-12-2004 12:16 PM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM



Advertisments