javascript 設定input框唯讀屬性 擷取disabled後的值並傳給後台

來源:互聯網
上載者:User

標籤:log   microsoft   方法   false   value   mic   text   lan   讀取   

input唯讀屬性

 
有兩種方式可以實現input的唯讀效果:disabled 和 readonly。自然兩種出來的效果都是只能讀取不能編輯,可是兩者有很大不同。Disabled說明該input無效,及其value不會傳遞給任何程式,比如asp、php等。
Readonly僅僅是無法編輯,不影響其值的傳遞。Disabled使用:<INPUT type=”text” name=”username” value=”james”disabled>
Readonly使用:<INPUT type=”text” name=”partNumber” value=”1500″ readonly>

 

disabled方式若要傳值,

 第一種方法:

可以添加隱藏的input標籤 <input name="hiddenplanyear" id="hiddenplanyear" type="hidden" class="textfield"  value=""  /> 

 第二種方法:

    <input type="text" class="input4" id="mainChkUserName" name="task.mainChkUserName" value="${sessionScope.QM_LOGIN_SESSION.name}"  disabled="true" />                    

在儲存的方法裡

$("#mainChkUserName").attr("disabled",false);

解除無效就行。

javascript 設定input框唯讀屬性 擷取disabled後的值並傳給後台

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.