【www.gdgbn.com--css3教程】





html5 <a href="http://www.gdgbn.com/blist-18-1.html" target="_blank" class="keylink">网页特效</a>表单验证实现方法

<script>

var form = document.getelementsbytagname("form")[0];
form.onsubmit = function (event) {
  for (var key in event) {
    dump(key + " = " + event[key] + "");
  }
 
  var i = this.length, el;
  while (i--, el = this[i]) {
    if (el.willvalidate) dump([el.id, el.validity.valid]);
  }

  return false;
};

form.oninvalid = function (event) {
  dump([].slice.call(event, 0));
  // alert("was not valid");
};

function dump(obj) {
  document.getelementbyid("debug").innerhtml += "

" + json.stringify(obj) + "
";
}
</script>



 

    round one
   

   
      
 

 


    round two
   
       
      
 

 



本文来源:http://www.gdgbn.com/css/27932/