OZONE Asylum
Forums
DHTML/Javascript
Stopping a form from posting with javascript
This page's ID:
28177
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Okay I finally figured it out. [quote] <script type="text/javascript"><!-- function textLimit(field, maxlen) { if (field.value.length > maxlen) { field.value = field.value.substring(0, maxlen); alert("You have exceeded 150 characters. The text field has been truncated to fit within 150 characters."); return false; } else { return true; } } //--></script> [/quote] Inside the Form Tag[code]onSubmit="return textLimit(this.body, 150)"[/code] Inside the Textarea Tag[code]onkeyup="textLimit(this.form.body, 150);"[/code] The onSubmit checks anything that is submitted when hitting the "enter" key or the click. The onKeyUp checks while text is entered into the actual field. Bitdamaged: Thank you for your ideas. What does the "form" part do? I removed the "form" from the onKeyUp event, but it broke. Could you enlighten me a bit as to why or what it does? Thank you. This patient is ready for his medication!
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »