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 admit up front, I do not know javascript. However, my work has asked me to build an intranet application that has grown much bigger than originally concieved (gotta love feature creep). They would like to have a form with a textarea field that has a character limit. I have gotten the javascript to stop and alert the user while they are typing. However, the code I am using does not notice when the user copies into the textarea, so I need to check the field before submitting the form. [code] function textLimit(field, maxlen) { if (field.value.length > maxlen) { field.value = field.value.substring(0, maxlen); alert("You have exceeded 150 characters"); return false; } } [/code] The code does give a warning and trim the field when the submit button is clicked, but it does not stop the form from being submitted. It does however, work when you hit enter. Is there a way to stop the form from submitting when you click on the submit button? Thank you, Dustin This patient is ready for his medication!
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »