Re: Best solution to tedious form validation?



On Mon, 29 Oct 2007 19:43:32 +0100, otrWalter@xxxxxxxxx <otrWalter@xxxxxxxxx> wrote:


In your suggestion you have type="text" and type="alpha" in the same input
tag.

Yes, sorry...


<input type="text"
id="first_name"
name="first_name"
datatype="alpha" <- new attribute int|alpha|phone|
email|etc
required="true" <- new attribute true|false
value="">

Thx for the catch

Well, let's invent HTML attributes? Invalid HTML means all bets are off on how anything will be handled, and only by the grace of UA's kind enough to process broken tagsoup HTML will it do anything resembling to what you want. Don't rely on that, use a real attribute. A classname comes to mind.

<input type="text" name="firstname" class="foo alpha required" value="">

It can more reliable be read using javascript, is valid, and is the place where you're supposed to put this kind of stuff.

http://www.w3.org/TR/html401/struct/global.html#adef-class
"The class attribute has several roles in HTML:
- As a style *** selector (when an author wishes to assign style information to a set of elements).
- For general purpose processing by user agents."
--
Rik Wasmus
.