i'm using the following code to try to check for blanks in textbox1 (lastname):
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
'
Sub Button1_Click(sender As Object, e As EventArgs)
response.redirect("homeApp.aspx")
End Sub
</script>
<html>
<head>
<script language="JavaScript">
function validatePage(sender, args)
{
if (document.getElementById("textbox1").value.length < 2)
{
args.IsValid = false;
return false;
}
else
{
args.IsValid = true;
return true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator id="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox1" ClientValidationFunction="validatePage"></asp:CustomValidator>
</p>
<p>
</p>
<p>
<asp:Label id="Label2" runat="server">something 2</asp:Label>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="home"></asp:Button>
</p>
<p>
<!-- Insert content here -->
</p>
</form>
</body>
</html>
i can use "document.getElementById("textbox1").value.length < 2)" to check for atleast one char in the textbox, but < 0 does'nt work for no chars in the textbox1 field.
how do you check for blanks?
Mike Johnson
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
'
Sub Button1_Click(sender As Object, e As EventArgs)
response.redirect("homeApp.aspx")
End Sub
</script>
<html>
<head>
<script language="JavaScript">
function validatePage(sender, args)
{
if (document.getElementById("textbox1").value.length < 2)
{
args.IsValid = false;
return false;
}
else
{
args.IsValid = true;
return true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator id="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox1" ClientValidationFunction="validatePage"></asp:CustomValidator>
</p>
<p>
</p>
<p>
<asp:Label id="Label2" runat="server">something 2</asp:Label>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="home"></asp:Button>
</p>
<p>
<!-- Insert content here -->
</p>
</form>
</body>
</html>
i can use "document.getElementById("textbox1").value.length < 2)" to check for atleast one char in the textbox, but < 0 does'nt work for no chars in the textbox1 field.
how do you check for blanks?
Mike Johnson