Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help on validating a text box using java script at client side. Plz help me..
Posted
Comments
virang_21 3-Sep-12 0:17am    
call your javascript function on button submit or onblur event of textbox

Try search on google[^].

A simple search here can solve your problem in quick time for sure.

This search shows 4,490,000 results, and many of those search result threads will surely solve your problem.

Try this thread: Validate TextBox[^]

and don't ask question like validating text box.
Be specific!
Specify exactly what it is you need help with.

Refer: How to ask a good question?[^]
 
Share this answer
 
Try this link if you are developing an ASP.net website
http://forums.asp.net/t/1356162.aspx/1[^]
 
Share this answer
 
XML
<form id="form1" runat="server">
    Your name:<br />
    <asp:TextBox runat="server" id="txtName" />
    <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your name!" />
    <br /><br />
    <asp:Button runat="server" id="btnSubmitForm" text="Ok" />
</form>



use required field validator and regualar expression validatior

http://asp.net-tutorials.com/validation/required-field-validator/[^]


http://asp.net-tutorials.com/validation/regular-expression-validator/[^]
 
Share this answer
 
Try This :

<script type="text/javascript">
function validate()
{
    if(document.getElementById("<%=txt1.ClientID %>").value=="")
    {
        alert("Please Enter Textbox Value");
        document.getElementById("<%=txt1.ClientID %>").focus();
        return false;
    }
}
</script>


And call on Button OnClientClick Event :
<asp:button id="btn1" runat="server" text="Click Here For Validation" onclientclick="return validate()" xmlns:asp="#unknown" />  

if any problem you got, please post it....
 
Share this answer
 
v2

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