JSFiddle - React, Tailwind, and code Playground

by GaryC123

HTML

<form method="post" name="FrontPage_Form1" id="pagemsg" onsubmit="return FrontPage_Form1_Validator(this)">
    <input type="hidden" name="Server" value="snpp.dapage.net">
    <p class="c1"><strong>Enter Page Text:</strong>
    </p>
    <p class="c1">
        <textarea rows="5" name="pageText" cols="40" onkeyup="//return taNCount(this, 200)"></textarea>
    </p>
    <p class="c1">Characters remaining : <span id=myCounter>200</span>
    </p>
    <p class="c1">Select list content -
        <select id="pageTarget" size="1" value="none" width="20" style="width: 200px">
            <input type="submit" value="submit">
</form>

JavaScript

function FrontPage_Form1_Validator(theForm) {

    if (theForm.pageText.value.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.value.replace(/\s/g, '');

    // 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;
    }

}