Forms with WuFoo
I've been listening to Technikwürze Podcast, Episode 104 (a german podcast about design and webstandards) and they've been talking about WuFoo, an online service to create HTML forms. You can create forms using drag and drop on their site. If you want their server side validation, their statistics and their database power, you can purchase a paid subscription plan, but what I want to point out today is their XHTML/CSS export feature.
When you create a form, click the code-button and choose “XHTML/CSS code only” on the right they'll serve you the correct XHTML and CSS code for the form you designed ready somewhat ready to include it into your web site. I moved all their CSS rules into some kind of “namespace” so they wouldn't interfere with my site's CSS rules (particularly my CSS files require the form to be in an element with class “wf” assigned to it and the IDs being used in the form are prefixed with “wf_”). I added some jQuery JavaScript for the cool eye candy-effects and that's it. Now I can easily insert WuFoo-generated forms in my site (and oh boy, I will).
Note that you will have to take care of form validation yourself - you're not using the WuFoo guys' servers and I didn't include client-side validation in my JavaScript.
If you'd like to use my modified CSS file and my jQuery JavaScript code scroll down for a highlighted version or get it here: CSS and jQuery JavaScript. The CSS and XHTML code has been released under a CreativeCommons Attribution 2.5 license and I'm hereby releasing the jQuery code under the same license.
/* - - - - - - - - - - - - - - - - - - - - -Title : Wufoo Form StructureAuthor : Infinity Box Inc.URL : http://wufoo.comLast Updated : September 30, 2007- - - - - - - - - - - - - - - - - - - - - */.wf {
margin:7px 0 15px 0;
text-align:center;
font-size:small;
background:#fff3e8;
font-family:Verdana,Geneva,Helvetica,sans-serif;}
.wf #wf_container {
text-align:left;
background:#fff3e8;}
.wf #wf_container, .wf #wf_top, .wf #wf_bottom, .wf #wf_footer {
margin:0 auto;
width:90%;
}.wf #wf_top, .wf #wf_bottom {
width:90%;
height:10px !important;
display:block !important;
}.wf #wf_top {margin-top:10px;}
.wf form.wufoo {
margin:20px auto 0 auto;
padding:0 0 20px 0;
}/* ----- LOGO ----- */.wf h1 {
margin:0;
padding:0;
min-height:0;
background-color:#dedede;
text-indent:-9000px;
text-decoration:none;
}.wf h1 a {
height:100%;
min-height:40px;
display:block;
/*background:url(/images/wflogo.png) no-repeat left top;*/overflow:hidden;
}* html .wf h1 a {
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="/images/wflogo.png", sizingMethod="crop");
}.wf img {
/*behavior: url(/images/iepngfix.htc);*/border:none;
}.wf .hide {
display:none !important;
}/* - - - - - - - - - - - - - - - - - - - - -Title : Wufoo Form FoundationAuthor : Infinity Box Inc.URL : http://wufoo.comLast Updated : November 13, 2007- - - - - - - - - - - - - - - - - - - - - */.wf .wufoo {font-family:Verdana,Geneva,Helvetica,sans-serif;
font-size:small;
}.wf .wufoo li {width:62%;}
.wf form ul {
margin:0;
padding:0;
list-style-type:none;
width:100%;
font-size:100%;
}.wf form li {
margin:0;
padding:4px 5px 2px 9px;
position:relative;
clear:both;
}.wf form li.focused label {
color: #fff3e8;}
.wf form input.focused,
.wf form textarea.focused,
.wf form select.focused {
border-color: #f00;}
.wf form li:after, .wf .buttons:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}.wf form li, .wf .buttons {
display: inline-block;
}* html .wf form li, * html .wf .buttons {
height: 1%;
}.wf form li, .wf .buttons {
display: block;
}* html .wf form li div {display:inline-block;}
.wf form li div, .wf form li span {
margin:0 4px 0 0;
padding:0 0 8px 0;
color:#444;
}.wf form li span {float:left;}
.wf form li div.address {padding-bottom:0;}
.wf form li div.left {
display:inline;
float:left;
width:47%;
}.wf form li div.right {
display:inline;
float:right;
width:47%;
}.wf .clear {
clear:both !important;
}/* ----- INFO ----- */.wf .info {
display:inline-block;
clear:both;
border-bottom:1px dotted #ccc;
margin:0 0 1em 0;
}.wf .info[class] {display:block;}
.wf .info h2 {
font-weight:normal;
font-size:160%;
margin:0 0 3px 0;
clear:left;
}.wf .info p {
font-size:95%;
line-height:135%;
margin:0 0 12px 0;
}/* ----- SECTIONS ----- */.wf form hr {display:none;}
.wf form li.section {
border-top:1px dotted #ccc;
margin-top:9px;
padding-top:13px;
padding-bottom:0px;
padding-left:9px;
width:97% !important;
}.wf form ul li.first {
border-top:none !important;
margin-top:0px !important;
padding-top:0px !important;
}.wf form .section h3 {
font-weight:normal;
font-size:110%;
line-height:135%;
margin:0 0 2px 0;
}.wf form .section p {
font-size:85%;
margin:0 0 10px 0;
}/* ----- FIELDS AND LABELS ----- */.wf label.desc {
line-height:150%;
padding:0 0 1px 0;
border:none;
color:#222;
display:block;
font-size:95%;
font-weight:bold;
}.wf label.choice {
font-size:100%;
display:block;
line-height:1.4em;
margin:-1.55em 0 0 25px;
padding:4px 0 5px 0;
color:#222;
width:90%;
}.wf form li div label, .wf form li span label {
margin:0;
padding-top:3px;
clear:both;
font-size:9px;
line-height:9px;
color:#444;
display:block;
}.wf input.text, .wf input.file, .wf textarea.textarea, .wf select.select {
margin:0;
font-size:100%;
color:#333;
}.wf input.text, .wf textarea.textarea, .wf .firefox select.select {
border-top:1px solid #7c7c7c;
border-left:1px solid #c3c3c3;
border-right:1px solid #c3c3c3;
border-bottom:1px solid #ddd;
background:#fff3e8;
/*url(/images/fieldbg.gif) repeat-x top*/;
}.wf input.text, .wf input.file {
padding:2px 0 2px 0;
}.wf input.currency {text-align:right;}
.wf input.checkbox, .wf input.radio {
display:block;
line-height:1.4em;
margin:6px 0 0 3px;
width:13px;
height:13px;
}.wf textarea.textarea {font-family:Verdana,Geneva,Helvetica,sans-serif;}
.wf select.select {font-family:Verdana,Geneva,Helvetica,sans-serif;
margin:1px 0;
padding:1px 0 0 0;
}.wf select.select[class] {
margin:0;
padding:1px 0 1px 0;
}*:first-child+html .wf select.select[class] {
margin:1px 0;
}.wf .safari select.select {
margin-bottom:1px;
font-size:120% !important;
}.wf span.symbol {
font-size:115%;
line-height:130%;
}.wf form li .datepicker {
float:left;
margin:.1em 5px 0 0;
padding:0;
width: 16px;
height: 16px;
cursor:pointer !important;
}/* ----- BUTTONS ----- */.wf input.btTxt {
padding:0 7px;
width:auto;
overflow:visible;
}.wf .buttons {
clear:both;
margin-top:10px;
}.wf .buttons input {
font-size:120%;
margin-right: 5px;
}/* ----- TEXT DIRECTION ----- */.wf .rtl .info h2,
.wf .rtl .info p,
.wf .rtl label.desc,
.wf .rtl label.choice,
.wf .rtl div label,
.wf .rtl span label,
.wf .rtl input.text,
.wf .rtl textarea.textarea,
.wf .rtl select.select,
.wf .rtl p.instruct,
.wf .rtl .section h3,
.wf .rtl .section p,
.wf .rtl input.btTxt {direction:rtl;}
/* ----- SIZES ----- */.wf .third {
width:32% !important;
}.wf .half {
width:48% !important;
}.wf .full {
width:100% !important;
}.wf input.small, .wf select.small {width:25%;}
.wf input.medium, .wf select.medium {width:50%;}
.wf input.large, .wf select.large, .wf textarea.textarea {width:100%;}
.wf textarea.small {height:5.5em;}
.wf textarea.medium {height:10em;}
.wf textarea.large {height:20em;}
/* ----- ERRORS ----- */.wf #wf_errorLi {
width:99%;
margin:0 auto;
background:#933000;
border:1px dotted red;
margin-bottom:1em;
text-align:center;
padding-top:4px;
padding-left:0px;
padding-right:0px;
}.wf #wf_errorMsgLbl {
margin:7px 0 5px 0;
padding:0;
font-size:125%;
color:#DF0000;
}.wf #wf_errorMsg {
margin:0 0 .8em 0;
color:#000;
font-size:100%;
}.wf #wf_errorMsg strong {
background-color: #FFDFDF;
padding:2px 3px;
color:red;
}.wf form li.error {
display:block !important;
background-color: #FFDFDF !important;
margin:3px 0;
}.wf form li.error label {
color:#DF0000 !important;
}.wf form p.error {
color:red;
font-weight:bold;
font-size:10px;
margin:-2px 0 5px 0;
clear:both;
}.wf .leftLabel p.error, .wf .rightLabel p.error {
margin-left:30%;
padding-left:15px;
}.wf .noI .leftLabel p.error, .wf .noI .rightLabel p.error {
margin-left:35%;
padding-left:15px;
}/* ----- REQUIRED ----- */.wf form .req {
float:none;
color:red !important;
font-weight:bold;
margin:0;
}/* ----- INSTRUCTIONS ----- */.wf form li.focused {
background: #351008;
color: #fff3e8;}
.wf form .instruct {
position:absolute;
top:0;
left:100%;
z-index:1000;
width:42%;
margin:0 0 0 8px;
padding:8px 10px 9px 10px;
border:1px solid #e6e6e6;
background:#f5f5f5;
line-height:130%;
font-size:80%;
color:#444;
visibility:hidden;
}.wf form .instruct small {font-size:105%;}
.wf form li.focused .instruct, .wf form li:hover .instruct {visibility:visible;}
/* ----- ALT INSTRUCTIONS ----- */.wf li.altInstruct .instruct,
.wf li.leftHalf .instruct,
.wf li.rightHalf .instruct {
visibility:visible;
position:static;
margin:-2px 0 0 0;
padding:0 0 7px 0;
background:none;
border:none;
width:100%;
font-size:9px;
clear:left;
}/* ----- LABEL LAYOUT ----- */.wf .leftLabel li,
.wf .rightLabel li,
.wf li.leftLabel,
.wf li.rightLabel {
width:97% !important;
padding-top:9px;
}.wf .leftLabel .small,
.wf .rightLabel .small {width:17%;}
.wf .leftLabel .medium,
.wf .rightLabel .medium {width:35%;}
.wf .leftLabel .large,
.wf .leftLabel textarea.textarea,
.wf .rightLabel .large,
.wf .rightLabel textarea.textarea,
.wf .leftLabel .address,
.wf .rightLabel .address {width:64%;}
* html .wf .leftLabel .small,
* html .wf .rightLabel .small {width:23%;}
* html .wf .leftLabel .medium,
* html .wf .rightLabel .medium {width:55%;}
* html .wf .leftLabel .large,
* html .wf .leftLabel textarea.textarea,
* html .wf .rightLabel .large,
* html .wf .rightLabel textarea.textarea {width:97%;}
.wf .leftLabel label.desc,
.wf .rightLabel label.desc {
float:left;
width:30%;
margin:2px 15px 0 0;
}.wf .rightLabel label.desc {text-align:right;}
.wf .leftLabel .address,
.wf .rightLabel .address {float:left;}
.wf .leftLabel p.instruct,
.wf .rightLabel p.instruct {
width:27%;
margin-left:5px;
}.wf .leftLabel .altInstruct .instruct,
.wf .rightLabel .altInstruct .instruct {
margin-left:30% !important;
padding-left:15px;
width:65%;
}.wf .leftLabel .buttons,
.wf .rightLabel .buttons {margin-left:15px;}
.wf .leftLabel .buttons input,
.wf .rightLabel .buttons input {margin-left:30%;}
/* ----- NO INSTRUCTIONS ----- */.wf .noI .instruct {
display:none !important;
}.wf .noI form li,
.wf .noI form li.buttons {
width:97% !important;
}.wf .noI form li.section {
padding-left:9px !important;
}/* ----- NO INSTRUCTIONS LABEL LAYOUT ----- */.wf .noI .leftLabel .large,
.wf .noI .leftLabel textarea.textarea,
.wf .noI .rightLabel .large,
.wf .noI .rightLabel textarea.textarea,
.wf .noI .leftLabel .address,
.wf .noI .rightLabel .address {width:60%;}
* html .wf .noI .leftLabel .small,
* html .wf .noI .rightLabel .small {width:23%;}
* html .wf .noI .leftLabel .medium,
* html .wf .noI .rightLabel .medium {width:55%;}
* html .wf .noI .leftLabel .large,
* html .wf .noI .leftLabel textarea.textarea,
* html .wf .noI .rightLabel .large,
* html .wf .noI .rightLabel textarea.textarea {width:97%;}
.wf .noI .leftLabel label.desc,
.wf .noI .rightLabel label.desc {width:35%;}
.wf .noI .leftLabel .buttons input,
.wf .noI .rightLabel .buttons input {margin-left:35%;}
/* ----- FIELD FLOATING ----- */.wf form li.leftHalf,
.wf form li.rightHalf {
width:46% !important;
}.wf li.leftHalf {
clear:left;
float:left;
}.wf li.rightHalf {
clear:none;
float:right;
}.wf li.leftHalf .medium,
.wf li.rightHalf .medium,
.wf li.leftHalf .small,
.wf li.rightHalf .small {width:100%;}
$(function() {
$('.wf input, .wf textarea, .wf select').each(function() {
if (this.type != 'submit' && this.type != 'button' && this.type != 'hidden') {
$(this).focus(function() {
var parent = $(this).parent();
while (!$(parent).is('li')) {
parent = $(parent).parent();
}$(parent).addClass('focused');
$(this).addClass('focused');
});
$(this).blur(function() {
var parent = $(this).parent();
while(!$(parent).is('li')) {
parent = $(parent).parent();
}$(parent).removeClass('focused');
$(this).removeClass('focused');
});
};
});
});