try this:-
Lets say you have a form like this:-
<form name="subscribe" id="subscribe_frm" action="#">
Your Name: <input type="text" name="name" id="txt_name" />
<input type="button" name="submit" value="Submit">
onclick="validateTextBox();" onleyup="validChar();" />
</input></form>
<script language=""javascript"">
function validateTextBox()
{
var txtN=document.getElementById('txt_Name');
if(txtN.value=='')
{
alert('Textbox can't be blank');
return false;
}
if(txtN.length>=[type the no of charaters you want the text to be limit])
{
alert('[Your prompt]');
return false;
}
}
function validChar()
{
var txtN=document.getElementById('txt_Name');
if(!txtN.value.match(/^[a-zA-Z]+$/))
{
alert('Enter only Characters');
return false;
}
}
</script>
Please don't forget to mark this as your answer if it helps you out. Queries are welcome