Sunday, June 28, 2009

Disabled Back Button

Hi, this simple code can prevent the back button of internet explorer to back in previous page.


function Back()
{ window.history.forward(); }
setTimeout("Back()", 0);
window.onunload = function() { null };

Friday, May 15, 2009

Accept Number Only

Hi, Today this is my first post in my asp.net topic (Even this year, this is my first post).

I will show on how to validate textbox input in numeric using javascript.

Step1:
function checkNum(event)
{
event = (event) ? event : window.event
var charCode = (event.which) ? event.which : event.keyCode
{
if ((charCode >= 48 && charCode <= 57) || (charCode == 8) || (charCode == 37) || (charCode == 39)) {
return true
}
return false
}

Step2:
In your form load event

txtnumeric.attributes.add("onKeyPress","return checkNum(event)")



This example showing that theirs another way to validate numeric input in a textbox.