Three methods to change the gray unavailable status after clicking the submit button

Source: Internet
Author: User

Method 1: Add directly to the button

After you click submit, the submit button becomes unavailable, which effectively prevents repeated submission. This Code implements this function. From the code, we can see that we only need to add this sentence on the submit button: onclick = "javascript: {this. disabled = true; document. form1.submit ();} ", which means that when the button is clicked, the unavailable attribute of the button is set to true, and the button becomes grayed out.

<Html> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "> <title> the button turns gray after the form is submitted </title> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Method 2: Use the onSubmit event and change the dimmed button to available.

Add the onSubmit event to the form. If the form is added with judgment, this method can be used directly. Remember to put it to the end; otherwise, it will be grayed out from the beginning, however, we added a code to make the submit button available,
This prevents repeated submission of information, and prevents code issues from leading to non-submission.

Copy codeThe Code is as follows:
<Form name = form1 action = "" onSubmit = "return closebut ()">
<Input name = "imageField" type = "submit" class = "inputbut" value = "OK"/> <br>
<Input type = "button" name = "hui" id = "hui" value = "make the submit button available" onclick = "document. form1.imageField. disabled = false"/>
</Form>
<Script>
Function closebut (){
Document. form1.imageField. disabled = true;
}
</Script>

Third, similar

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-type "content =" text/html; charset = gb2312 "> <meta name =" keywords "content =" webmaster, webpage special effects, js special effects, js scripts, scripts, ad code "/> <meta name =" description "content =" www.jb51.net, webmasters special effect network, webmasters must js special effects and ad code. A large number of high-quality js special effects, providing high-quality AD code downloads, all in the webmaster special effect network "/> <title> after the webpage special effect form is submitted, the button changes to the gray effect 3 </title> </pead> <body> script home, webmasters must provide high-quality webpage special effects and advertisement code. </Body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.