[ale] javascript question
Richard Bronosky
Richard at Bronosky.com
Sat Aug 8 02:10:06 EDT 2009
Agreed. You should not trust javascript to play any part in the
validation _enforcement_. If you choose to use AJAX to inform the user
of an error before they submit, cool. But if the open up firebug and
delete/override your onsubmit/onclick methods, you don't want your
server to just accept it.
About using server side code to generate the JS to show/hide error
messages... Instead of using JS to get it to show, use CSS with an I'd
selector. So, all your error divs have class='errordiv'. The error div
for the email field has id='erroremail', for phone id='errorphone',
etc. Your standard css file has:
.errordiv {color:red; display:none;}
When you return after an error, you add a style tag after the one that
src's the standard css file and it has:
#erroremail {display:block}
That's it, no JS. It works for everyone, even if they use NoScript
plugins, like most of the subscribers to this list do.
On 8/7/09, Mike Harrison <meuon at geeklabs.com> wrote:
>> Suggestions? I'm trying to not rebuild the page by hand with the
>> pre-populated fields, but that might be what I have to do.
>
> Do it server-side and give them back a filled in form.
>
> Relying on Javascript for this will get you a lot of garbage.
>
> And anything you use Javascript for input validation on,
> needs to be double checked on the server as well.
> You can NOT assume that the clients JavaScript will
> work.. or work properly.
>
>
>
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
--
Sent from my mobile device
.!# RichardBronosky #!.
More information about the Ale
mailing list