J
John
Hi,
I have an asp.net form where if the user enters an
incorect date I change the color of the textbox to red and
also display a label field with a message saying the date
is invalid. What I would like to do is to have some way to
trap the event where the user changes the date and reset
the color of the textbox to white and change the error
lablel to hidden. I want to do this before the page gets
submitted back to the server so I've tried various
Javascript routines but can't seem to get this to work.
(I'm using a date field here as example but the textbox
could be anything I ant to edit in the code-behind).
Here is the latest thing I tried, but no luck.
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"
onsubmit="ChangeColor()">
<asp:TextBox id="tbDate" style="Z-INDEX:
120; LEFT: 240px; POSITION: absolute; TOP: 191px"
tabIndex="6" runat="server" Width="86px"></asp:TextBox>
<asp:Label id="lblDate" style="Z-INDEX:
119; LEFT: 45px; POSITION: absolute; TOP: 195px"
runat="server">As of Date </asp:Label>
<asp:button id="btnOK" style="Z-INDEX:
103; LEFT: 333px; POSITION: absolute; TOP: 393px"
tabIndex="18" runat="server" Width="61px"
Text="OK"></asp:button>
<asp:button id="btnCancel" style="Z-INDEX:
106; LEFT: 432px; POSITION: absolute; TOP: 393px"
tabIndex="19" runat="server" Width="61"
Text="Cancel"></asp:button>
<asp:label id="lblError" style="Z-INDEX:
101; LEFT: 32px; POSITION: absolute; TOP: 431px"
runat="server" Visible="False" Width="565px"></asp:label>
</form>
<script language="javascript">
function ChangeColor()
{
document.forms(0).elements
['lblError'].Hidden = 'True';
// document.forms(0).tbDate.BackColor
= "White";
}
</script>
</body>
Thanks,
JOhn Ritchie
I have an asp.net form where if the user enters an
incorect date I change the color of the textbox to red and
also display a label field with a message saying the date
is invalid. What I would like to do is to have some way to
trap the event where the user changes the date and reset
the color of the textbox to white and change the error
lablel to hidden. I want to do this before the page gets
submitted back to the server so I've tried various
Javascript routines but can't seem to get this to work.
(I'm using a date field here as example but the textbox
could be anything I ant to edit in the code-behind).
Here is the latest thing I tried, but no luck.
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"
onsubmit="ChangeColor()">
<asp:TextBox id="tbDate" style="Z-INDEX:
120; LEFT: 240px; POSITION: absolute; TOP: 191px"
tabIndex="6" runat="server" Width="86px"></asp:TextBox>
<asp:Label id="lblDate" style="Z-INDEX:
119; LEFT: 45px; POSITION: absolute; TOP: 195px"
runat="server">As of Date </asp:Label>
<asp:button id="btnOK" style="Z-INDEX:
103; LEFT: 333px; POSITION: absolute; TOP: 393px"
tabIndex="18" runat="server" Width="61px"
Text="OK"></asp:button>
<asp:button id="btnCancel" style="Z-INDEX:
106; LEFT: 432px; POSITION: absolute; TOP: 393px"
tabIndex="19" runat="server" Width="61"
Text="Cancel"></asp:button>
<asp:label id="lblError" style="Z-INDEX:
101; LEFT: 32px; POSITION: absolute; TOP: 431px"
runat="server" Visible="False" Width="565px"></asp:label>
</form>
<script language="javascript">
function ChangeColor()
{
document.forms(0).elements
['lblError'].Hidden = 'True';
// document.forms(0).tbDate.BackColor
= "White";
}
</script>
</body>
Thanks,
JOhn Ritchie