用js代码去除空格,如下:
<script language="javascript" type="text/javascript">
String.prototype.Trim = function() {
return this.replace(/(^s*)|(s*$)/g, "");
}
function CheckData() {
var Uname = document.getElementById('<%=txtUname.ClientID %>').value;
var Upwd = document.getElementById('<%=txtUpwd.ClientID %>').value;
if (Uname.Trim() == "") {
alert('用户名不可以为空!');
return false;
}
if (Upwd.Trim() == "") {
alert('密码不可以为空!');
return false;
}
return true;
}
</script>