4.8.10

User not to enter Numberor Decimal in textbox..

By AJAX:
http://forums.asp.net/p/1288474/3802854.aspx
-------------
1.How to check if a textbox contains a number

http://bytes.com/topic/asp-net/insights/654366-how-check-if-textbox-contains-number

2. check user not enter decimal value in textbox

txtCourseFee.Attributes["OnKeyPress"] = "javascript:CheckDecimal(event);";

function CheckDecimal(event) {

var isNS4 = (navigator.appName == "Netscape") ? 1 : 0;

if (!isNS4) {
if (event.keyCode < 46 || event.keyCode > 57)
event.returnValue = false;
}
else {

if (event.which < 46 || event.which > 57) return false;
}
}



3.) If textbox contain No number then Blank it.

txtCourseFee.Attributes["onblur"] = "javascript:isNotNumberThenBlank(" + txtCourseFee.ClientID + ");";

function isNotNumberThenBlank1(obj) {
if (obj.value.search(/[^0-9^.^ ]/) != -1) {
obj.value = "";
obj.focus();
alert('Please enter only numeric value');
return false;

}

return true;
}


4.) Confirmation on button click
btnSave.Attributes["OnClick"] = "javascript:return confirmation();";

function ConfirmSave() {
var retVal = confirm("This will save Student information. Do you want to continue ?");
return retVal;
}

No comments: