Wednesday, 7 August 2013

Only Numeric & Only Character Value in Text Box by javascript

Only Numeric Value In Text Box by Javascript
<script type="text/javascript" language="javascript">
function numeric(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode > 31 && ((charCode >= 48 && charCode <= 57) || charCode == 46))
return true;
else
{
alert('Please Enter Numeric values.');
return false;
}
}
</script>

<asp:TextBox ID="txtName" runat="server" onkeypress="return character(event)" ></asp:TextBox>

Only Character in Text Box using Javascript

<script type="text/javascript" language="javascript">
function character(e)
{
isIE = document.all ? 1 : 0
keyEntry = !isIE ? e.which : event.keyCode;
if (((keyEntry >= '65') && (keyEntry <= '90')) || ((keyEntry >= '97') && (keyEntry <= '122')) || (keyEntry == '46') || (keyEntry == '32') || keyEntry == '45')
return true;
else
{
alert("Please enter character only");
return false;
}
}
</script>