DRAG DROP
You create a webpage that includes the following HTML markup: (Line numbers are included for reference only.)
You need to ensure that a form cannot be submitted unless the INPUT element contains the word OK.
Which five actions should you perform in sequence? (To answer, move the appropriate actions from
the list of actions to the answer area and arrange them in the correct order.)
Answer: See the explanation.
Explanation:
If the ‘}’ in Box 4 wasn’t there, this would be correct. As it is, the parentheses are unbalanced.
https://api.jquery.com/first-selector/
it also says when it contains the word ok, now it seems the value of the input needs to equal the word ok.
Shouldn’t this be : if ($(‘input:first’).val().indexOf(“OK”) !== -1) {…} ?
Type OK to validate form.
$(“form”).submit(function() {
if($(“input:first”).val().indexOf(“OK”) != -1) {
console.log(“true”);
}
return false;
});
Type OK to validate form.
$(“form”).submit(function() {
if($(“input:first”).val().indexOf(“OK”) != -1) {
return true;
}
return false;
});
This code will have a error the parentheses are not properly coded