Saturday, August 18, 2007

JavaScripts to Allow Alfabets+Numeric+Space for a TextBox

Write this in the Head Part of the HTML Side
<script language="Javascript">
function fnAllowAlphaNumericSpace()
{
if ((event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode != 46 && event.keyCode != 32) && (event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122)) event.returnValue = false;
}
</script>

Write this in the Page_Load of the WebForm thats the CodeBehind Side.

this.txtFirstName.Attributes["OnKeyPress"] = "Javascript:return fnAllowAlphaNumericSpace()";

1 comments:

Urit said...

Keep up the good work.