Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Script c10 Question 9 (1 point) Which of the following coding sequences can

ID: 3917913 • Letter: J

Question

Java Script c10

Question 9 (1 point)

Which of the following coding sequences can be used to validate the data on a form and submit it to the server?

Question 9 options:

Within the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid.

Within the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid or the preventDefault method if it isn’t.

Within the click event handler of a submit button, validate the data and then issue the submit method of the form if the data is valid

Within the click event handler of a submit button, validate the data and then issue the submit method of the form if the data is valid or the preventDefault method if it isn’t.

Save

Question 10 (1 point)

Code example 10-1
$(document).ready(function() {
    $("#contact_me").change(
        function() {
            if ($("#contact_me").attr("checked")) {
                $(":radio").attr("disabled", false);
            } else {
                $(":radio").attr("disabled", true);
            }
        }
    );
});

(Refer to code example 10-1) What does this code do?

Question 10 options:

It disables or enables a specific radio button when an element is checked or unchecked.

It disables or enables all radio buttons when an element is checked or unchecked.

It disables or enables a specific check box when an element is checked or unchecked.

It disables or enables all check boxes when an element is checked or unchecked.

Save

Question 11 (1 point)

Code example 10-1
$(document).ready(function() {
    $("#contact_me").change(
        function() {
            if ($("#contact_me").attr("checked")) {
                $(":radio").attr("disabled", false);
            } else {
                $(":radio").attr("disabled", true);
            }
        }
    );
});

(Refer to code example 10-1) What do the jQuery selectors in this code select?

Question 11 options:

individual elements by id only

disabled radio buttons only

an individual element by id and disabled radio buttons

an individual element by id and all radio buttons

Save

Question 12 (1 point)

Code example 10-2
$(document).ready(function() {
    $("#member_form").submit(
        function(event) {
            var isValid = true;
            .
            .
            var password = $("#password").val().trim();
            if (password == "") {
                $("#password").next().text("This field is required.");
                isValid = false;
            } else if ( password.length < 6) {
                $("#password").next().text("Must be 6 or more characters.");
                isValid = false;
            } else {
                $("#password").next().text("");
            }
            $("#password").val(password);
            .
            .
            if (isValid == false) { event.preventDefault(); }
        }
    );
});

(Refer to code example 10-2) What does the preventDefault() method in this code do?

Question 12 options:

It cancels the change() event method of the form.

It cancels the submit() event method of the form.

It triggers the change() event method of the form.

It triggers the submit() event method of the form.

Save

Question 13 (1 point)

Code example 10-2
$(document).ready(function() {
    $("#member_form").submit(
        function(event) {
            var isValid = true;
            .
            .
            var password = $("#password").val().trim();
            if (password == "") {
                $("#password").next().text("This field is required.");
                isValid = false;
            } else if ( password.length < 6) {
                $("#password").next().text("Must be 6 or more characters.");
                isValid = false;
            } else {
                $("#password").next().text("");
            }
            $("#password").val(password);
            .
            .
            if (isValid == false) { event.preventDefault(); }
        }
    );
});

(Refer to code example 10-2) Why is the following line of code necessary after the if-else statement?
$("#password").val(password);

Question 13 options:

The val() method removes the password entered by the user, so this code displays the original password.

The next() method replaces the password entered by the user, so this code displays the original password.

The text() method replaces the password entered by the user, so this code displays the original password.

The trim() method removes extra spaces entered by the user, so this code displays the trimmed password.

Save

Question 14 (1 point)

Which of the following methods is not one of the methods that trigger events?

Question 14 options:

focus()

change()

leave()

select()

Save

Question 15 (1 point)

In the following code, what does the line of code in the else clause do?
$(document).ready(function() {
    $("#join_list").click(function() { // join_list is a regular button
        if ( $("email_address").val() == "") {
            alert("Please enter an email address.");
        } else {
            $("#email_form").submit();
        }
    });

});

Question 15 options:

It handles the submit() event method.

It triggers the submit() event method.

It handles the click() event method.

It triggers the click() event method.

Within the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid.

Within the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid or the preventDefault method if it isn’t.

Within the click event handler of a submit button, validate the data and then issue the submit method of the form if the data is valid

Within the click event handler of a submit button, validate the data and then issue the submit method of the form if the data is valid or the preventDefault method if it isn’t.

Explanation / Answer

Question 9 : Answer : Within the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid

To validate the  data on a form and submit it to the server use the procedure as In the the click event handler of a regular button, validate the data and then issue the submit method of the form if the data is valid

Question 10 : Answer : It disables or enables all radio buttons when an element is checked or unchecked.

The given code is used to enable or disable radio buttons the jquery selector :radio is used in it.

Question 11 : Answer : An individual element by id and all radio buttons .

The jquery selector in this code slects all the type of radio buttons.

Question 12 : Answer :  It cancels the submit() event method of the form.

In the given code the event.preventDefault() method stops the default action of an element from happening. in the given example it is submit button.

Question 13: Answer :  The val() method removes the password entered by the user, so this code displays the original password.

Question 14 : Answer :  leave()

The other methods focus() , change() , select() trigger the events but leave() does not.

Question 15 : Answer :  It triggers the submit() event method.

The else clause , else {
            $("#email_form").submit();
        }
is used to trigger the submit event after the data validation

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote