form submit tutorial example

http://phpschool.com/link/tipntech/78427

HTML

<form name="myform" actopm="/echo/html/" method="post">
    <table border="1" width="100%">
        <tr>
            <th>input text</th>
            <td><textarea maxlength=3 title="a" name="a" placeholder="input value"></textarea></td>
        </tr>
    </table>
    <div class="center">
      <input type="button" name="b" value="get input text"/>
      <input type="button" name="c" value="load text"/>
      <input type="submit" value="submit"/>
    </div>
</form>

CSS

.center{text-align:center;margin-top:1em;}

JavaScript

var form = document.forms.myform,
    elem = form.elements;

elem.c.onclick = function() {
  alert('load');
	elem.a.value = "1\n2\n3\n";
}
elem.a.onchange = function(){
    alert('form name is : ' + this.form.name);
};
elem.b.onclick = function(){
    alert('input value is : ' + elem.a.value);
};
form.onsubmit = function(){
	  
    if(!elem.a.value){
        alert('please input text.');
        elem.a.focus();
        return false;
    }
    alert(elem.a.value.length)
    var t = JSON.stringify(elem.a.value);
    alert(t);
    alert(t.length);
    return true;
}