function UnamePwdValidation()
{
if (document.getElementById("<%=Txt_UserName.ClientID%>").value=="")
{
alert("Enter Username");
document.getElementById("<%=Txt_UserName.ClientID%>").focus();
return false;
}
if(document.getElementById("<%=Txt_Password.ClientID %>").value=="")
{
alert("Enter Password");
document.getElementById("<%=Txt_UserName.ClientID %>").focus();
return false;
}
}
< asp:ImageButton ID="Submit" OnClientClick="return UnamePwdValidation()" runat="server" ImageUrl="images\Go.jpg" TabIndex="3" />
Javascript function to allow only alphabets (lower and upper case).
function AllowCharacterOnly(myevent)
{
var Val = (myevent.which) ? myevent.which : myevent.keyCode
if ((Val > 64 && Val <> 96 && Val < type="text" id="txtChracter" onkeypress="return AllowCharacterOnly(event)" style="color: rgb(255, 102, 0); font-weight: bold;">Javascript to allow user to enter only numeric value.
function AllowNumericValue(myevent)
{
var charVal = (myevent.which) ? myevent.which : myevent.keyCode
if (charVal > 31 && (charVal <> 57))
{
return false;
}
return true;
}
input type="text" id="Text2" onkeypress="return AllowNumericCharacters(event)"
Javascript function to show an alert if user entered a non numeric value.
function ValidationCheckforNumeric(txtVal)
{
var len = txtVal.value.length;
var charVal = 0;
for (var i=0;i
{
charVal = txtVal.value.charCodeAt(i);
if (!((charVal >= 48 && charVal <= 57))) { alert("Only Numeric Values are Allowed"); txtVal.value = ''; txtVal.focus(); return false; } } return true; } input type="text" id="txtNumber" onchange='ValidationCheckforNumeric(this)' Javascript code for checking null value in Textbox.
function CheckForEmptyTextbox()
{
var s;
var txtValue;
txtValue = document.getElementById('TextBox1');
if (txtValue.value == '')
{
s = confirm('TextBox1 is blank, do you want to continue?');
return s;
}
return true;
}
Button1.Attributes.Add("onclick", "javascript: CheckForEmptyTextbox();");
On button click - how to bring up browsers emailing box using javascript.
INPUT TYPE="button" VALUE="Send Email." onClick = "parent.location= 'mailto:mymailid@gmail.com'"
Show Timer on status bar using Javascript
function showtime ()
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes <>= 12) ? " P.M." : " A.M."
window.status = timeValue;
}
Call this function on load of the form.
Check the browser type using javascript.
if(navigator.appName=="Netscape")
{
alert("Browser is Netscape Navigator.");
}
else if (navigator.appName == "Microsoft Internet Explorer")
{
alert("Browser is Microsoft Internet Explorer.");
}
else
{
alert("Neither Netscape Navigator nor Internet Explorer.");
}
Set Control Focus using Javascript code.
body onload="document.forms[0]['TextBox1'].focus();"
PopUp Window
window.open('pop_up.html', 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=200,height=130')
Cookies (JavaScript)
http://www.pages.org/javascript/index.html
No comments:
Post a Comment