Jump to content

Textarea to contain only alphabets!


saravanataee

Recommended Posts

Dear all,

I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that.

 

I know it can be done with regular expressions. But i m not aware of how to do.

 

Can some one help with that.

 

Here is my script.

<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
 limitField.value = limitField.value.substring(0, limitNum);
} else {
 limitCount.value = limitNum - limitField.value.length;
}
}

</script>
<tr>
<td valign="top" align="left">Description</td>
<td valign="top">:</td>
<td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);"
onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);">
</textarea><br>
<font size="1">(Maximum characters: 100)<br>
You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td>
</tr>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.