troubleshooting Question

Javascript to check values does not seem to execute --

Avatar of Phonebuff
PhonebuffFlag for United States of America asked on
HTMLWeb ApplicationsWeb Development
25 Comments2 Solutions156 ViewsLast Modified:
I have some VERY old html that I am moving into a new environment and the form works,  but the javascript to ensure that the text box is not empty or more than 400 characters does not seem to function --  (Yes it was done way back in FrontPage).

Now it looks like this..  
<script language = "JavaScript"  type="text/javascript" >
function FrontPage_Form1_Validator(theForm) {

if (theForm.pageText.length==0 ) {
        alert("Please enter a message in the Text box.");
        theForm.pageText.focus();
        return (false);
    }

// first remove all spaces using the following regex
StrToCheck= theForm.pageText.replace(/^s+|s+$/, '');

// then we check for the length of the string if its 0 or not
if( StrToCheck.length==0) {
        alert("Please enter a message in the Text box.");
        theForm.pageText.focus();
        return (false);
}

    if (theForm.pageText.value.length > 400) {
        alert("Please enter at most 400 characters in the Text box.");
        theForm.pageText.focus();
        return (false);
    }
    return (true);
}
</script>

-----------------------

<form action="/cgi-bin/dapicgi.php" method="post" name="FrontPage_Form1" id="pagemsg" onsubmit="return autocomplete=off FrontPage_Form1_Validator(this)" >

I have tried a few variations of the onsubmitt with no luck..  

Hope someone here see's my problem --
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros