Form problem summary and best practices

Source: Internet
Author: User

In my work, I often encounter many Forms Submission and form alignment problems. Below I will summarize my problems. You are also welcome to add.

1) form alignment

It took some time to align the form, even if vertical-align: middle was set. Later, this problem was solved by adding margin-top:-2px. This actually correspondsFontThere is a lot of relationship between the settings, our font isFont:12px/1.5 Arial,; The first choice is the Arial font, so it must be solved by adding the margin-top:-2px (I use the 12px font). In fact, you only need to replace the fontTahoma fontThen set vertical-align: Middle. You can.

2) Form submission problems

There are two methods. The first method is to directly write form + IFRAME or form in HTML. Form + IFRAME is generally used to submit content, and the browser does not jump, on this page, I am generally used to solve cross-origin problems. I will use ajax to submit without cross-origin. Form is a separate form submission, which is generally used for login-like submission. The page first jumps to the logon page. You can add your own address at the end, and then return to this page. It is generally done by adding a parameter.

The second method is to dynamically create a form through Js. The main advantage of this method is that you do not need to write a lot of HTML on the page. We automatically create a form through the script and append it to the end of the body, but pay attention to it. Document. if you create an IFRAME in the form of createelement, you must dynamically create an IFRAME in the form of innerhtml. For form, the input hidden options in the form are added in the form of innerhtml, the value to be added may not pass post because it has quotation marks. Best way

It is created using document. createelement. Since there may be many inputs, we recommend that you add a document fragment for processing so that you do not operate the DOM node every time.

3) Chinese problems

Do I need to transcode the Chinese characters in the form? No. I transcoded it during the initial development. I recorded the error here.

You are welcome to make a brick.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.