C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » JavaScript »

how to validate the checkedlistbox thru javascript


Posted Date: 11 Jul 2006      Posted By: sudhagar      Member Level: Silver     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

Author: bhaskar    12 Jul 2006Member Level: BronzeRating: 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>



Author: sourirajan saravanan    17 Jul 2006Member Level: GoldRating: 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>





Author: B. Gopal Surya Prakash    28 Jan 2009Member Level: SilverRating: 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: JavaScript



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use