如何用javascript来判断文本框是否为空?
对象: <asp:textbox id= "txtPageNumber " runat= "server "> 1 </asp:textbox>
功能:用来输入Page Number(页码数)
要求:判断文本框内是否为空,若为空,则自动把输入的数字变为1
------解决方案--------------------if(document.getElementById( 'txtPageNumber ').value == " ")
document.getElementById( 'txtPageNumber ').value = 1
------解决方案--------------------String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, " ");
}
function assign(control)
{
return control.value.trim()== " ";
}