html disabled 和readonly,disabled 引起的form表单提交问题
来源:互联网 发布:首席财务官 知乎 编辑:程序博客网 时间:2024/06/05 00:22
先看看这两个属性在效果和使用上的区别
READONLY and DISABLED both remove the functionality of the input field, but to different degrees. READONLY locks the field: the user cannot change the value. DISABLED does the same thing but takes it further: the user cannot use the field in any way, not to highlight the text for copying, not to select the checkbox, not to submit the form. In fact, a disabled field is not even sent if the form is submitted.
对于diabled掉的form 表单,
<form id="product_form">
<fieldset id="static_fields" disabled="disabled">
<div class="form-group">
<label class="col-lg-2 control-label" for="product_name">产品名称</label>
<div class="input-group col-lg-6 ">
<input class="form-control static" id="product_name" name="projectName" title="" data-toggle="tooltip" data-placement="bottom" data-original-title="产品名称">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="capital">募集金额</label>
<div class="input-group col-lg-6 ">
<span class="input-group-addon"><i class="fa">¥</i></span>
<input type="number" min="1" max="100000000" class="form-control static" id="capital" title="" name="capital" data-toggle="tooltip" data-placement="bottom" data-original-title="募集金额">
<span class="input-group-addon"><span>.00</span></span>
</div>
</div>
</fieldset>
</form>
1,我们会发现 input 里的value 在调试时候不能像原来那样查看,必须去prpperties中去查看
2,用js 获取表单内容,会获取到空值,input的值也不会被传到服务器
var form = $('#product_form').serialize();
$.post(url, form, function(data) {
if (data && data.code) {
if (data.code == 0) {
console.log('goto product info page.');
// 刷新页面
alert('修改成功');
} else {
alert(data.message + "[" + data.code + "]");
}
} else {
alert("内部错误");
}
});
调试会发现 form="projectID=&projectName=&capital=" 类似的空值,
所以,我们必须在用js提交表单时候,主动将diabled属性去掉 $('#static_fields').removeAttr("disabled");
- html disabled 和readonly,disabled 引起的form表单提交问题
- HTML表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- 表单中Readonly和Disabled的区别
- Android图库中照片刷新性能优化措施
- Operation not allowed after ResultSet closed--操作mysql数据库
- android中生成excel
- TCP/IP知识理解(下)
- DOM addClass MOveClass
- html disabled 和readonly,disabled 引起的form表单提交问题
- extjs基本属性
- iOS中 setNeedsDisplay和setNeedsLayout方法的不同
- markdowm
- teechart 用法
- python学习之数据类型(基本元素)
- 如何获取ResultSet的行数和列数
- 华盛顿大学--初探深度学习
- android HandlerThread源码分析