Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

how to textbox value empty / null check without page reload/refreshing in javascript.
Posted
Updated 22-Mar-21 2:53am

how to textbox value empty / null check without page reload/refreshing in javascript
You need any client side event raised such that you can access the control on client side in JavaScript and then check the value in control.

Example:
HTML
<input type="button" id="check" onclick="CheckValue();" />

<script>
//JS code
function CheckValue()
{
  // Access the control here
  // Check the value of the control and take appropriate action. 
}
</script>


Try out. Post specific issue if you face any.
 
Share this answer
 
Try returning false from your javascript function. Use Like this:
JavaScript
funciton fnValidate()
{
     var txt = document.getElementById('TextBox1');
     if(txt.value == "")
     {
         return false;
     }
}

Alternate Way:
You can try using RequiredFiedValidator control of asp.net in the TextBox.


--Amit
 
Share this answer
 
Comments
azizulhoque.bd 8-Jan-13 5:43am    
I try! you code but it not solution my problem. I want textbox value null check without reloading page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900