对我来说,有一个简单但非常复杂的问题。我使用JavaScript来提交表单,但我的JavaScript将空数据转换为JSP。
1)HTML
<form method="post" name="frm" class="form-horizontal"
data-ajax = "false" enctype="multipart/form-data">
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input type="text" maxlength="10" id="user_id" name="id" class="input-block-level" placeholder="ID"/>
<a href="#" data-ajax="false"><img src="images/confirm.png" onclick="checkId()"></a>
</div>
</div>
</div>
2)JavaScript
<script type="text/javascript">
function checkId() {
var u_id = document.frm.user_id.value;
if (u_id == "") {
alert("please input your id");
document.frm.user_id.focus();
return;
}
document.frm.action = 'CheckUserId.jsp';
document.frm.submit();
}
</script>