Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add alert to function 1

Status
Not open for further replies.

JohnShell

Technical User
Aug 29, 2003
35
US
Hi,
Inserted function to limit amount of characters in a textarea. Want to add alert to that function that informs users they reached input limit - how do I do it?
Code:
<script language="javascript" type="text/javascript">
function imposeMaxLength(projects, MaxLen)
{
	return(projects.value.length <= MaxLen);
}
</script>

Input code:
Code:
<textarea name="projects" id="projects" cols="37" rows="5" onkeypress="return imposeMaxLength(this, 50);">
 
[tt]function imposeMaxLength(projects, MaxLen)
{
[red]//[/red]return(projects.value.length <= MaxLen);
if (projects.value.length<=MaxLen) {
return true;
} else {
alert("Length exceeds max allowed.");
return false;
}
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top