0
Form Validation
hi what is " && n2.value ! "? function validate() { var n1 = document.getElementById("num1"); var n2 = document.getElementById("num2"); if(n1.value != "" && n2.value != "") { if(n1.value == n2.value) { return true; } } alert("The values should be equal and not blank"); return false; }
4 Respostas
+ 4
In addition to Nomeh's answer, take a look at this text about logical operators:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators
+ 3
You can separe conditions in if () with &&, and the code in execute if all the conditions are true
+ 3
Sorry, my english isn't very good
+ 1
***.value != ""
Means that the value of the input element must not be empty which means "" in .js