On Sun, Aug 14, 2011 at 07:07:09PM -0700, Bobby wrote:
> Thanks for replying.
> A small problem I ran into when emulating the html5 placeholder
> attribute is that emulating the behavior involves setting the input's
> value.
> A value that then has the chance of being submitted, if the value is
> never cleared by either the user focusing or binding a function to the
> submit event.
>
> So I was left with writing a custom deserialization method to check if
> the submitted value is equal to the placeholder value.
> Anyway, thanks again for replying.

The javascript code should register an 'onsubmit' handler for forms
containing inputs with placeholders which would erase any placeholders
before they get sent to the server.

I just picked one of the libs listed on the modernizr polyfill list at
random, and it does appear to do just that.   You might want to try it out.
This is the one I looked at (though I suspect they all probably do the
right thing):

   https://github.com/mathiasbynens/Placeholder-jQuery-Plugin

Try out his demo:

   http://mathiasbynens.be/demo/placeholder

Just hit submit --- you can see it submits empty values for all the
form fields.  (The form uses method=GET, so just look at the URL you
end up at to see the submitted values.)


Jeff

> On Aug 13, 12:09 pm, Jeff Dairiki <[email protected]> wrote:
> > On Fri, Aug 12, 2011 at 02:57:18PM -0700, Bobby wrote:
> > > The desired outcome is an input field filled with a default value that
> > > is removed when the field is focused.
> >
> > I haven't actually tried this yet (sorry), but I plan on just using the
> > HTML5 placeholder attribute.
> >
> > As far as deform is involved this would involved modifying the default
> > templates to set the 'placeholder' attribute on text input and textarea
> > tags.  I think I'd make the template pull the placeholder value from
> > field.schema.placeholder.
> >
> > To support older browsers, I plan on using a bit of javascript to
> > emulate the HTML5 behavior.  The modernizr wiki has a list of
> > "polyfills", several of which claim to do the job (scroll down to "Web
> > Forms - input placeholder"):
> >
> >  https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyf...
> >
> > Jeff
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/pylons-discuss?hl=en.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to