javascript validation to a textfield to check for null.


Textbox empty check using javascript,empty textbox validation with javascript ,JavaScript tutorial validate form: Textboxes,Client Side Validation using JavaScript for textbox empty check . how to write javascript alert message for empty textbox , javascript validation to a textfield to check for null.

If you have a textbox and you want to check that the box must not be null using javascript. the below javascript code will help you.


JavaScript Example Code


<script>
  function checknull()
  {
    if(document.getElementById("txttext").value=="")
    {
      alert("Please enter value.");
      return false;
    }
  }
</script>


You just call this function on Blur to event to check textbox is empty or having value.
onblur=" checknull() ;" -- add this to text box property Like below

<asp:TextBox ID="txttext" runat="server" Text="" onblur=" checknull();"></asp:TextBox>

All The Best !!!


Tags: ,

Join Us!