ASP.NET - Validations Problem ? - Asked By aileni giri on 12-Nov-12 02:06 AM

i have  a page on that i have one  textbox and fileupload control and i applied validation controls on it.
i have written the javascript code  to when the button submit ,the textbox border color changed to Red color ,if there is no
valid data. .

my problem is  when i enter the data into textbox still the textbox  color is in red color,..i Applied RequiredField Validator control.

here is  my code
<html xmlns="">
<head id="Head" runat="server">

    <style type="text/css">
        font-family: Verdana;
        font-size: 12pt;
        border: solid 2px Red;
    <form id="FormControl" runat="server">
      <asp:FileUpload ID="fu1" runat="server" />
      <asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="fu1" ErrorMessage="must have to upload">
      <br /><br />
      <asp:TextBox ID="txtUname" onblur="return claerAll();" runat="server"></asp:TextBox>
      <asp:RequiredFieldValidator ID="rfv2" runat="server" ControlToValidate="txtUname" ErrorMessage="Shouldn't Blank">
      <br /><br />
      <asp:Button ID="btnSubmit" runat="server" Text="Submit" />

<script type="text/javascript">
    function WebForm_OnSubmit()
      if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false)
        for (var i in Page_Validators)
            var control = document.getElementById(Page_Validators[i].controltovalidate);
            if (!Page_Validators[i].isvalid)
              control.className = "ErrorCtrl";
              control.className = "ErrorCtrl1";

          catch (e) { }
        return false;
      return true;
Chiranjeevi S replied to aileni giri on 21-Nov-12 01:39 AM
I have checked your code and it is working fine.
You have to click the button after entering text into textbox.
aileni giri replied to Chiranjeevi S on 23-Nov-12 03:45 AM
what  i need is  when i leaving textbox  ,the red color border should be go,with out clikcing on submit button.