Brian schrieb:
> Here's an idea:
> 
> <label for="foo" class="validate 000h000h00"></label>
> <input name="foo" id="foo" type="text" />
> 
> It's HTML 4.01, will probably pass for strict, and it semantically
> separates the validation from the field.  The idea is that for every label
> with class "validate", there's a validation mask somewhere within the
> classes that should be applied to the associated field.  This can
> conceivably apply to any input, if you want to do the work.  This could
> guarantee a set number of checkboxes are checked, one of the radio buttons
> has been chosen, a select is not left on its default value, etc.
> 
> Some gotchas:
> * The only legal place to put the mask would be as a class.  It would be a
> Bad Thing if you tried to make it the ID, since each element should have
> only one unique ID, and you may want to apply the same mask to a different
> field.  The bonus here is that you can also style by validation mask.  How
> cool would that be?  (e.g.: Use a background-image of a phone icon for
> fields that want a phone number.)
> 
> * One would need to create a language for expressing a mask using only
> alphanumerics and underscores, since that's what's legal in a class. 
> This, in turn, may require enough regexp magic to make the best of us go
> running for the aspirin bottle.  :)
> 
> * One would need to support two legal HTML syntax cases - <label
> for="foo"> and <label><input /></label> .
> 
> * For broken use cases (e.g.: class="validate" -- no mask is provided),
> one would want to bail out silently rather than throwing an error.
> 
> What do you think?  I'm almost feeling crazy enough to take a whack at it.
>  It all starts with $("label"), how hard could it be?  :)
> 
> - Brian


I like that pretty much... Styling derived from the mask is really cool!

Go Brian, go Brian!


I have made something similiar by the way for the Plazes Geotagr (hm, is 
that the reason why I like it?), where you can automatically upload 
pictures to Flickr and have them geotagged.

If an image from your collection is tagged already, it gets a class of 
"untag" along with the id of the image separated by white space and if 
not it has a class of "tag" of course. The script knows what to do by 
these classes...


-- Klaus


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to