dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online Membersnaveensanagasetti
SSharma
amitmehta
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » JavaScript »

how to validate the checkedlistbox thru javascript


Posted Date: 11 Jul 2006      Posted By:: sudhagar     Member Level: Silver    Member Rank: 0     Points: 2   Responses: 3



hi i wanna give a validation to checkedlistbox..
@least 1 item shud be select in the list else i wanna give a message




Responses

#62763    Author: bhaskar      Member Level: Bronze      Member Rank: 0     Date: 12/Jul/2006   Rating: 2 out of 52 out of 5     Points: 2

Java Script Function

<script language="javascript">
function func1()
{

if (document.all('chk').checked==true )
{

alert("You have selected the value");

}
else
{
alert("Please Select the Check Box")

}
}
</script>



 
#63324    Author: sourirajan saravanan      Member Level: Gold      Member Rank: 237     Date: 17/Jul/2006   Rating: 2 out of 52 out of 5     Points: 2



<HTML>
<HEAD>
<TITLE>Check Box Example </TITLE>
<SCRIPT LANGUAGE="javascript">
function fun_Validate()
{
if ((document.frm.chk[0].checked==false) && (document.frm.chk[1].checked==false))
{
alert("Select food style!");
}
else if ((document.frm.chk[0].checked==true) || (document.frm.chk[1].checked==true))
{
alert("Thanks for your option");
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="frm">
<TABLE>
<TR><TD colspan="2">Food Style</TD></TR>
<TR><TD><INPUT TYPE="checkbox" name="chk">Vegetarian</TD></TR>
<TR><TD><INPUT TYPE="checkbox" name="chk">Non-Vegetarian</TD></TR>
<TR><TD colspan="2"> </TD></TR>
<TR><TD colspan="2"><INPUT TYPE="button" NAME="btnValidate" VALUE="Submit" onClick="fun_Validate()"></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>





 
#340937    Author: B. Gopal Surya Prakash      Member Level: Silver      Member Rank: 862     Date: 28/Jan/2009   Rating: 2 out of 52 out of 5     Points: 3

To achieve this first of all u need to understand how does your checkbox list is rendered into browse[see viewsource of browser]

Now you should be able to understand the below code. &

Java Script Function

<script language="javascript">
function func1()
{

if (document.all('checkbo').checked==true )
{

alert("Selected");

}
else
{
alert("Please select one")

}
}
</script>






 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Previous : It is possible vbscript and javasript in same page
Return to Discussion Forum
Post New Message
Category:



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.