Javascript validate empty fields -


can me on how validate javascript form if following fields empty? doesn't seem work code.

function addvalidation(){         var w = document.forms["shop"]["w"].value;         var t = document.forms["shop"]["t"].value;         var = document.forms["shop"]["a"].value;         var c = document.forms["shop"]["c"].value;         var s = document.forms["shop"]["s"].value;         var c = document.forms["shop"]["c"].value;          if (w == "" || t =="" || == ""|| c == "" || s == "" || c == "") {                 alert("mandatory fields must filled out");                 return false;         } 

http://jsfiddle.net/tn2fvh4p/91/

http://jsfiddle.net/tn2fvh4p/68/

please use following code

function addvalidation(){      var w = document.getelementbyid("w").value;      var t = document.getelementbyid("t").value;      var = document.getelementbyid("a").value;      var c = document.getelementbyid("c").value;      var s = document.getelementbyid("s").value;      var c = document.getelementbyid("c").value;       if (w == "" || t =="" || == ""|| c == "" || s == "" || c == "") {              alert("mandatory fields must filled out");              return false;          } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -