(Functional) Pretty Forms
August 12th, 2005Forms have been a rough spot when it comes to style. There’s just only so much you can do; the browsers just don’t allow the kind of styling I’d like. The issue is often discussed, and a nice demonstration of the problem can be found over at Roger Johansson’s site.
There have also been a few solutions attempted. Until I really started working on this, the best solution I was able to find was at badboy media. But there were problems with that solution, so I went about finding my own way.
My end goal was to make my forms look like this:

There were a couple of other requirements I had (that were not necessarily met in other solutions):
- Needs to be non-intrusive. I just want to include a javascript file, css file, and maybe an onLoad event. The rest should take care of itself.
- Must respect preselected elements. For example if, when a page loads, a checkbox is automatically selected, it needs to stay selected. This was critical, I plan on using this for a large application
- Must also trigger events! For example, if my select box has an onChange event, that event must get triggered when I choose an item.
- Must allow me to size my form fields however I like. Many other solutions use a single image to replace a form. That doesn’t cut it. I need this to work on all my form fields, regardless of size.
In other words, I should be able to drop this thing on any page in just a few lines, and it should deliver great looking forms without interrupting any existing functionality.
So how’d it go?
It was that 3rd requirement above that proved tricky.
The sample page has a few events on a couple of different elements. When triggered, there should be a bit of text a the bottom saying so. The one caveat here is that the checkboxes ignore the onClick event. It will respond to onChange though. Also, I only bothered with onClick and onChange, but it would be very easy to add other events as well.
So want to use/tinker with this? Here is a zip file that contains everything.
To put the effect on your own page simply include the following in your html:<script type="text/javascript" src="[your path here]/prettyForms.js”></script>and<link rel="stylesheet" href="[your path here]/prettyForms.css” type=”text/css” media=”screen” />
Then include this event in your onload:<body onload="prettyForms()">
Depending on how your page is built this might muck up your layout. All of the form elements will now be floated to the left:float:left;
I always float my form fields like this so it’s not a problem, but I could see how this might cause a little bit of tweaking on your page.
Also, the layout is affected by the doctype. I generally use strict whenever possible, so put this at the top of your page too:< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">and make sure your html validates and your css validates.
So that’s that. Let me know what you think. I’d especially like to know how it goes on various browsers/platforms. I have tested on IE6 and Firefox on the PC, and Firefox and Safari on the Mac. The borders aren’t quite right on Safari, I’ll get that fixed and post an update.
There are a number of things I’m still working on:
- Keyboard navigation: Using tab works reasonably well, but falls apart a bit on the select element.
- Although it’s a little-used element, I need to put something together for the mulitple select element for completeness.
- I gotta clean up the javascript… it’s not all that tidy, and uses only basic IE/mozilla recognition. I need to get this up to a more complete level. But as it is, it works.
- Here’s a big one: I need to find a way to handle the “next level” events. For example, say checkbox one causes checkbox two to become checked. The first box’s event will fire, checking box 2, but it won’t look like it. The problem is that altering a form element with javascript does not fire that element’s events. Tricky. I’m still working on this one.
Well they look great, but the select box crashes Safari every time!
Yeah… Safari. I tested that after publishing this. I noticed it doesn’t look right (at all), but I didn’t have trouble with crashing(!). What kind of crash? Hang the browser? Or Crash, Bam, Blam?
I’m part way through a Safari solution, but these people I do work for keep interrupting me…
http://www.mattkruse.com/javascript/checkboxgroup/index.html
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
add overflow: auto to textarea
[...] Functional Pretty Forms [...]
[...] js badboy.media.design : Niceforms slayeroffice | code | custom checkbox Ryan Brill | Form Highlighting Redux Trimming form fields | And all that Malarkey Bitácora de Webmaster » Mandar un Formulario con un Enlace Intenta - Seleccionar todo en un textarea Script.aculo.us Select Box Agave Group » Blog Archive » (Functional) Pretty Forms CRIR: Checkbox Radio Input Replacement [...]
Wondering if you have a working file input css/javascript fix. Otherwise its great man! very nice.
[...] 1. Prettyforms by Agave group [...]
Thanks
http://www.andhapp.com/blog/index.php?p=14
I hope the portability issue hasn’t been discouraging for you. Your code is good: It’s the fact that the industry threw away the standards (I won’t be more specific than that) and now we’re in the process of putting them all back as we discover the reasons they were there in the first place.
Thanks for a very usefule contribution,
Ernie
I hope the portability issue hasn’t been discouraging for you. Your code is good: It’s the fact that the industry threw away the standards (I won’t be more specific than that) and now we’re in the process of putting them all back as we discover the reasons they were there in the first place.
Thanks for a very useful contribution,
Ernie
This is eye candy the way i love it. Thank u 4 sharing it. But now i’ve to go on and apply this 4 our formz :O)
the polarizer
great documentation thanks a lot !
regards…
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] (Functional) Pretty Forms - agavegroup.com [...]
Very cool form. It looked perfect in Firefox, Opera, Safari when I tested. Only minor issue in IE7, for button.
Great work!
I was wondering if anyone has a fix for dropdown with “&” signs in them? They get converted into the html “& a m p ;” once they are selected.
It’s propably just making the fixSelects() iterate through the charachters, and convert it to a “\&”. But my js skills are limited, so I’m rather lost.
Adding “file” and “password” in fixTextBoxes() looks great too :)
Great work, The form is very cool. I like it.
Looks great, thanks.
Nice optic. Cannot wait to use it for our contact form. Thx for sharing it. Keep on working that way
Looks very great !
[...] http://www.agavegroup.com/?p=35 [...]
[...] Functional Pretty Forms [...]
[...] Badboy Niceforms Functional Pretty Forms CSS-Only, Table-less Forms Subtraction: Free Form for All - Standardkonforme Online-Formulare Accessible CSS Forms [...]
First of all:
Great job! :)
Second:
Is there a way to put a scrollbar into SELECT tag? I have many options in one and it gets messy, it stretches my website a long way down.
Thankyou.
the link to the zip file is broken :(
Please put a scrollbar in the select-box
It works but seems very very slow in IE
[...] Functional Pretty Forms [...]
[...] 功能é½å…¨çš„è¡¨å• å®Œå…¨é‡‡ç”¨CSSæŠ€æœ¯çš„è¡¨å• ç•Œé¢æ¸…æ™°çš„è¡¨å• [...]
[...] Functional Pretty Forms [...]
Thats nice !
Great work …
This still remains one of the best scripts of it’s kind. Has anyone developed a scroll for it yet? Badly needed!
Very nice but why empty password area ? :’(
[...] [...]
Has anyone managed to get these styles to work on password boxes yet? Awesome forms, I want to use them in my site but can’t get password box to work, also for some strange reason the dropdown box isn’t wide enough…..
[...] Functional Pretty Forms [...]
[...] 7. Functional Pretty Forms [...]
About the password box is easy.
in the file prettyForms.js just add this funtion:
//apply look to password boxes
function fixPasswordBoxes(){
inputs = document.getElementsByTagName(”input”);
for(i=0;i
function fixPasswordBoxes(){
inputs = document.getElementsByTagName(”input”);
for(i=0;i
[...] Agave Group [...]
[...] Functional Pretty Forms » Daca iti place ceea ce vezi, te poti abona la al meU RSS feed. » Daca nu folosesti un client RSS, te poti abona prin email [click aici]. [...]
Could you give us an example of one that is centered in a page as a multi search search form? I am trying to get this to work for my layout at. http://www.plentyoftorrents.com Also what should I delete from the css since I only need this for one button and a drop down form and search text area? Looks awesome so I hope I can get it working.
[...] 15. Functional Pretty Forms Forms have been a rough spot when it comes to style. There’s just only so much you can do; the browsers just don’t allow the kind of styling I’d like. The issue is often discussed, and a nice demonstration of the problem can be found over at Roger Johansson’s site. There have also been a few solutions attempted. Until I really started working on this, the best solution I was able to find was at badboy media. But there were problems with that solution, so I went about finding my own way. [...]
[...] Functional Pretty Forms [...]
[...] 33. Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Formularios funcionales y bonitos [...]
[...] Formularios funcionales y bonitos [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Agave Group » Blog Archive » (Functional) Pretty Forms [...]
[...] Functional Pretty Forms Subtraction: Free Form for All - Standardkonforme Online-Formulare [...]
[...] Functional Pretty Forms [...]
http://www.bjmr999.com/zxmr/gmzx/20080719644.htm
[...] Functional Pretty Forms [...]
http://www.interpretation-union.com
http://www.topdvdsofts.com/Products/dvd-ripper-platinum.html
[...] (Functional) Pretty Forms : [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Read more: Agave Group » Blog Archive » (Functional) Pretty Forms [...]
[...] 32. PrettyForms [...]
[...] 32. PrettyForms [...]
[...] 32. PrettyForms [...]
[...] 32. PrettyForms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]
[...] Functional Pretty Forms [...]