Question: JavaScript Can Validate Input Please input a string that has an even length: Submit function myFunction() { var x, text; //Get the value of the
JavaScript Can Validate Input
Please input a string that has an even length:
function myFunction() {
var x, text;
//Get the value of the input field id="numb"
x = document.getElementById("character").value;
// If x is a Number or A STRING THAT
//has a length than is odd then it is not valid
{
// input is not OK
} else {
text = "Input OK";
}
document.getElementById("WEBT2300").innerHTML = text;
}
Question 10 options:
|
| if (!isNaN(x) || (x.length % 2 != 0)) { text = "Input not valid"; } else { // text is ok text = "Input OK"; } |
|
| if (isNaN(x) || (x.length % 2 != 0)) { text = "Input not valid"; } else { // text is ok text = "Input OK"; } |
|
| if (isNaN(x) && (x.length % 2 == 0)) { text = "Input not valid"; } else { // text is ok text = "Input OK"; } |
|
| if (isNaN(x) && (x.length % 2 != 0)) { text = "Input not valid"; } else { // text is ok text = "Input OK"; } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
