<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Untitled Page</title><script type="text/javascript">function CompareDate(txtfrom, txtto) {var From = txtfrom.value;var To = txtto.value;var strSplitFrom = From.split('/')var myDateFrom = new Date();myDateFrom.setFullYear(strSplitFrom[2], strSplitFrom[1] - 1, strSplitFrom[0]);var strSplitTo = To.split('/')myDateTo = new Date();myDateTo.setFullYear(strSplitTo[2], strSplitTo[1] - 1, strSplitTo[0]);if (myDateFrom > myDateTo) {alert("Start date can not greater than End date.");txtfrom.focus();return false;}else {return true;}}</script></head><body><form id="form1" runat="server"><div><p><b>DD/MM/YEAR Format</b></P>From Date<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox><br/>To Date<asp:TextBox ID="txtto" runat="server"></asp:TextBox><br/><asp:Button ID="Button1" runat="server" Text="Click" OnClientClick="return CompareDate(txtfrom,txtto);" /></div></form></body></html>![]()
Monday, May 23, 2011
Javascript FromDate to Date Validation
Friday, May 20, 2011
Hide and Visible using Javascript
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function forRentClicked() {
if (document.getElementById('<%=CheckBox1.ClientID%>').checked == true) {
RadioButtonList1.style.display = 'block';
}
else {
RadioButtonList1.style.display = 'none';
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" Text="Items" onClick="forRentClicked()" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" style="display:none;">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
output :
How to "hide" or make "visible" in javascript when i "check or uncheck" a checkbox
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script language="javascript" type="text/javascript">
function forRentClicked() {
if (document.getElementById('<%=CheckBox1.ClientID%>').checked == true) {
div1.style.display = 'block';
}
else {
div1.style.display = 'none';
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" onClick="forRentClicked()" />
</div>
<div id="div1">
<asp:Label ID="Label1" runat="server" Text="Rental rate per week:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Output:
Make Enter Button As Tab Key
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script src="script/JScript.js" type="text/javascript"></script>
<script type="text/javascript">
function keypressed(e) {
var intKey = (window.Event) ? e.keyCode:e.which;
if (intKey == 13) {
document.getElementById('<%=text2.ClientID %>').focus();
return false;
}
}
function keypressed2(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text3.ClientID %>').focus();
return false;
}
}
function keypressed3(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text4.ClientID %>').focus();
return false;
}
}
function keypressed4(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text5.ClientID %>').focus();
return false;
}
}
function keypressed5(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text6.ClientID %>').focus();
return false;
}
}
function keypressed6(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text7.ClientID %>').focus();
return false;
}
}
function keypressed7(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text8.ClientID %>').focus();
return false;
}
}
function keypressed8(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text9.ClientID %>').focus();
return false;
}
}
function keypressed9(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=text10.ClientID %>').focus();
return false;
}
}
function keypressed10(e) {
var intKey = (window.Event) ? e.keyCode : e.which;
if (intKey == 13) {
document.getElementById('<%=DropDownList1.ClientID %>').focus();
return false;
}
}
function keypressed11(e) {
var intKey = (window.Event) ? e.keyCode:e.which;
if (intKey == 13) {
document.getElementById('<%=Button1.ClientID %>').focus();
return false;
}
}
function Validation1() {
if (document.getElementById('<%=DropDownList1.ClientID %>').value == "Select::") {
alert('select DropDownList');
document.getElementById('<%=Button1.ClientID %>').focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox onkeypress="return keypressed(event)" id="text1" runat="server" Width="200px" ></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed2(event)" id="text2" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed3(event)" id="text3" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed4(event)" id="text4" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed5(event)" id="text5" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed6(event)" id="text6" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed7(event)" id="text7" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed8(event)" id="text8" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed9(event)" id="text9" runat="server" Width="200px"></asp:TextBox><br/>
<asp:TextBox onkeypress="return keypressed10(event)" id="text10" runat="server" Width="200px"></asp:TextBox><br/>
<asp:DropDownList ID="DropDownList1" runat="server" onkeypress="return keypressed11(event)">
<asp:ListItem>Select::</asp:ListItem>
</asp:DropDownList><br/>
<asp:Button ID="Button1" runat="server" OnClientClick="return Validation1();" Text="Button" OnClick="Button1_Click" />
<asp:Label id="lblMsg" runat="server" forecolor="Red" text="* Username must be alphanumeric with no special characters"></asp:Label>
</div>
</form>
</body>
</html>
Monday, May 9, 2011
Enter Key Acts As Tab Key using Javascript
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script language="javascript" type="text/javascript">
function testing(event,number)
{
if( event.keyCode == 13 )
{
var wow = document.getElementById(number);
wow.focus();
}
}
</script>
<title>Making enter key work as tab for Fire Fox</title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"
Text="Make enter key work as tab for Fire Fox"></asp:Label>
<table class="style1">
<tr>
<td>
<asp:TextBox ID="TextBox2" runat="server" onkeydown="testing(event,2)"
TabIndex="1"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<input id="2" type="text" tabindex="3" onkeydown="testing(event,3)" /></td>
</tr>
<tr>
<td>
<input id="3" type="text" tabindex="2" onkeydown="testing(event,'ab')" /></td>
</tr>
<tr>
<td>
<asp:TextBox ID="ab" runat="server" onkeydown="testing(event,'cd')"
TabIndex="4"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="cd" runat="server" onkeydown="testing(event,'ef')"
TabIndex="10"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ef" runat="server" onkeydown="testing(event,'RadioButton1')">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" onkeydown="testing(event,'ListBox1')"/>
</td>
</tr>
<tr>
<td>
<asp:ListBox ID="ListBox1" runat="server" onkeydown="testing(event,'TextBox1')"></asp:ListBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" onkeyup="testing(event,'Button1')"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" UseSubmitBehavior="false" runat="server" Text="Button" Width="166px" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Sunday, September 5, 2010
Wednesday, July 28, 2010
Bind the DropDownList On Selected IndexChanged based on the ID



