.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

javascript to validate textbox

Posted By: Ramesh     Posted Date: August 09, 2010    Points:2   Category :ASP.Net
My requirement is that i have a webpage with one textbox,submit button.
when ever user doesnt enter any text and clicks submit then he must get an alert box thatis by running javascript written in htmlsource page.
anybody please help me by code or any url's


Author: Sunil Yadav       [Moderator]      
Posted Date: August 09, 2010     Points: 5   

check below solution.

alert("Please enter text.");
return false;
hope it helps.

Author: Syed Shakeer Hussain             
Posted Date: August 09, 2010     Points: 5   

<script type="text/javascript">

function method()
if((document.getElementById("txt").value).length == 0)
alert("The textbox should not be empty");

<form id="frm">
<input type="text" id="txt" onblur="javascript:method();" />

Author: willium             
Posted Date: August 09, 2010     Points: 5   

A textbox can be validated using a JavaScript by using a redirection to the JavaScript page ..say I need to check for username then we redirect the form to login.js (JavaScript for the checking) by the action attribute.

Want to get-on Google's first page and loads of traffic to your website? Hire a SEO Specialist from Ocean Groups [url=http://oceangroups.org/]seo pecialist [/url]

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend