JQUERY VALIDATION FOR ASP.NET CONTROLS
Jquery Blank Field Validation
if(document.getElementById("<%=CompanyNameTextBox.ClientID %>").value=="")
{
alert("Please
Enter Company Name");
document.getElementById("<%=CompanyNameTextBox.ClientID %>").focus();
return false;
}
Jquery Contact No Validation
<asp:TextBox
ID="ContactNoTextBox" runat="server"
onkeypress="return chklen(this);"></asp:TextBox></td>
function chknum3()
{
if((event.keyCode >=48
)&&(event.keyCode<=57))
{
alert("Branch Name Should Be In Character..");
return false;
}
else
{
return true
;
}
}
Jquery Number Length Validation
function chklen(id)
{
if (id.value.length <11)
{
return chknum();
}
else
{
alert("Mobile Number Length should not be greater than 11
Digits::::");
return false;
}
}
Jquery Email Validation
if(document.getElementById("<%=EmailTextBox.ClientID%>").value=="")
{
alert("Please
Enter EMail Id....")
return false;
}
else
{
var at="@"
var dot="."
var
str=document.getElementById("<%=EmailTextBox.ClientID%>").value;
var
lstr=str.length;
var
lat=str.indexOf(at);
var
ldot=str.indexOf(dot);
var
pat=/^.+@.+\..{2,3}$/;
if(str.indexOf(at)==-1
||str.indexOf(at)==0 ||str.indexOf(at)==lstr)
{
alert("Invalid
Email Id.. Please Try Again..")
return false;
}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr
)
{
alert("Invalid
Email Id.. Please Try Again..")
return false;
}
}
Jquery Delete/Confirmation:
function
del()
{
if(confirm("Are You Sure?")==true)
{return true;
}
else
{
return false;
}
}
onclientclick="return
del()";
Jquery ToolTip:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript">
// Create the
tooltips only on document load
$(document).ready(function()
{
// Notice the use
of the each() method to acquire access to each elements attributes
$('.show-tooltip').each(function()
{
$(this).qtip({
content: 'be
a good one', // Use the tooltip attribute of
the element for the content
style: 'dark'
// Give it a crea mstyle to make it stand out
});
});
});
</script>
<a href="http://google.com/" class="show-tooltip"
><asp:Button ID="Button1"
runat="server"
Text="Love"
/></a>
Jquery Hide and Show via flipping:
<script type="text/javascript">
$(document).ready(function(){
$(".flip").click(function(){
$(".panel").slideToggle("slow");
});
});
</script>
<style type="text/css">
p.flip
{
margin:0px;
padding:5px;
text-align:center;
border:solid 1px
#c3c3c3;
}
div.panel
{
height:163px;
width: 1268px;
display:none;
<%--optional to fill color--%>background-color:Lime;
}
</style>
<input id="Button1" type="button" value="button" class="flip" />
<div class="panel">Anything</div>
Jquery Hide and Show via flipping:
SHORT WINDOW OPEN
CLOSE
<script type="text/javascript">
function
closepopup()
{
window.close();
}</script>
on
cs.file................................................
string
scrname;
scrname = @"<SCRIPT
language='javascript'> closepopup();" + "</SCRIPT>";
this.RegisterStartupScript("MyAlert", scrname);
Jquery open window pop up
<script type="text/javascript">
<!--
function popup(url)
{
var width = 500;
var height =
270;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+',
height='+height;
params += ', top='+top+', left='+left;
params += ',
directories=no';
params += ',
location=no';
params += ',
menubar=no';
params += ',
resizable=no';
params += ',
scrollbars=no';
params += ',
status=no';
params += ',
toolbar=no';
newwin=window.open(url,'windowname5', params);
if
(window.focus) {newwin.focus()}
return false;
}
// -->
</script>
<a href="javascript: void(0)"
onclick="popup('addexam1.aspx')">click here to view</a>