понедельник, 1 февраля 2010 г.

http://googlesystem.blogspot.com/2008/05/customize-google-docs-forms.html

http://googlesystem.blogspot.com/2008/05/customize-google-docs-forms.html

Customize Google Docs Forms

Adding forms as a way to include information in a Google Spreadsheet was one of the best decisions made by Google lately as it increased the adoption of the product. Unfortunately, Google doesn't offer options to customize the forms or validate the input. But just because Google hosts the forms for you doesn't mean you can't copy the code on your web pages and edit it.

After copying the code, you can edit the CSS rules to customize the form, remove the references to external files or the links to Google's terms of use. This article has a list of pretty forms customized only using CSS. If some of the fields need to have a certain format (for example: dates, email addresses etc.), you may include some JavaScript code that validates the input before submitting the form or after a certain field loses the focus. This JavaScript library includes the code for some common validations, so you can use it without too much programming effort. LiveValidation requires to write some code, but it validates the input as you type.

Here's a simple styled form that validates the first field using an annoying alert (you can submit the form only if JavaScript is enabled):

In what year did you first use Google?
What search engines did you use before Google?


And here's the code:


Validation only works when JavaScript is enabled in your browser. Note that if you edit the form using Google Docs, you need to change the code from your web page.

{ Thanks, A. }
************************
Just curious: does setting the action attribute to an empty string, and then giving it a value in the onsubmit event, like

< form action="" onsubmit="this.action='http://...'; if(..) .. else .." >

behave differently than simply setting its value using the action attribute, like

< form action="http://..." onsubmit="if(..) .. else .." >

By the way: Google might have changed the names of the parameters:

< input type="text" name="single:1" >

in current (embedded) forms would read

< input type="text" name="entry.1.single" >

So, a warning: not only when YOU change your form definition you need to revise your HTML, but also when Google changes something...

Комментариев нет:

Отправить комментарий