Question

In: Computer Science

6. What does the XXXXX need to be replaced with to trigger the function in the...

6. What does the XXXXX need to be replaced with to trigger the function in the following code when the submit button is pressed:

<form XXXXX="submitIt()">                                                                                                       

   Enter name: <input type="text">

  <input type="submit">           

</form> 
  1. Suppose there is the following form element:
<input type="number" name="quantity" >

Rewrite the HTML code above using the required attribute to let the input accept only a number from 1 to 20.

  1. Suppose there is the following form element:
Country code: <input type="text" name="country_code"

XXXXXX="[A-Za-z]{3}" title="Three letter country code">

Rewrite the HTML code above substituting XXXXX with the attribute name that lets the input accept only 3 alphabetic characters:

  1. Suppose there is the following form element:
Username: <input type="text" name="usrname" XXXXX>

Rewrite the HTML code above substituting XXXXX with the attribute name that tells the Web page to check the presence of a value before the HTML form can be submitted:

  1. Suppose there is the following form element:
Country <input type="text" name="country" value="USA" XXXXX>

Rewrite the HTML code above substituting XXXXX with the attribute name that prevents user from typing data into the text input:

  1. Write the JavaScript code to get all parameters from an HTTP request
  2. Write the correct regular expression pattern for a phone number field with the format XXX-XXX-XXXX
  3. If urlParms contains the collection of all parameters from an HTTP request, write the correct code to get only the zip code parameter
  4. Suppose that you have the following partial HTML page and JavaScript that needs to check an input numeric field. What is the JavaScript function XXX in the “if” statement than can do the task of input checking?
<script>

  function myFunction() {

    var inpObj = document.getElementById("id1");

    if (!inpObj.XXX()) {                                                                                                                                                                        document.getElementById("demo").innerHTML =   inpObj.validationMessage; 

                              } else {                              

                          document.getElementById("demo").innerHTML =      "Input OK";

                         }

               }                                                                                                              

</script>

<p>Enter a number and click OK:</p>

<input id="id1" type="number" min="100" max="300" required>

<button onclick="myFunction()">OK</button>

<p>If the number is less than 100 or greater than 300, an error message will be   displayed.</p>

<p id="demo"></p>
  1. Suppose that the following code needs to check if an input field is present or not. What is the XXX that is needed to do the task?
function validateForm() {

   var x = document.forms["myForm"]["fname"].value;

      if (XXX) {

          alert("Name must be filled out");

          return false;

    }

}

  1. Suppose there is an input element to contain a birthday. What is the correct HTML code to specify that the birthday value cannot be earlier than Jan 1, 1900
  2. Suppose there is an input number that can only contain even values, positive or negative (-4, -2, 0, 2, 4…). What is the correct HTML syntax for validation:
  3. Write a JavaScript function that has two arguments, multiplies them and returns the result. Invoke the function and then print the result using alert
  4. Use the getElementById method to find the <p> element, and change its text to "Hello":
<p id="demo"></p>

<script>

?????       = "Hello";

</script>

Solutions

Expert Solution

Here is anwers of all of your qestions, Please hit that like or thumbs-up button<3

All the values of XXX is in fornt of Answer as well as in your code which is in Bold format.

Q1 )

Answer : - action

<form action="submitIt()">                                                                                                       

   Enter name: <input type="text">

  <input type="submit">           

</form> 

Q2)

Answer : - onKeyPress="if(this.value.length>20) return false;"

Alternative : -  min="1" max="20"

<input type="number" name="quantity" onKeyPress="if(this.value.length>20) return false;">

Alternative : - <input type="number" name="quantity" min="1" max="20">

Q3)

Answer :- pattern

Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">

Q4)

Answer: required

Username: <input type="text" name="usrname" required>

Q5)

Answer: disabled

Country <input type="text" name="country" value="USA" disabled>

Q6)

Answer : - checkValidity()

<script>

  function myFunction() {

    var inpObj = document.getElementById("id1");

    if (!inpObj.checkValidity()) {                                                                                                                                                                        document.getElementById("demo").innerHTML =   inpObj.validationMessage; 

                              } else {                              

                          document.getElementById("demo").innerHTML =      "Input OK";

                         }

               }                                                                                                              

</script>

Q7)

Answer :- x == ""

function validateForm() {

   var x = document.forms["myForm"]["fname"].value;

      if (x == "") {

          alert("Name must be filled out");

          return false;

    }

}

Q8) Suppose there is an input element to contain a birthday. What is the correct HTML code to specify that the birthday value cannot be earlier than Jan 1, 1900.

Answer: - <input type="birthdate" id="myDate" name="bday" min="1900-01-01">

Q9) Suppose there is an input number that can only contain even values, positive or negative (-4, -2, 0, 2,) What is the correct HTML syntax for validation

Answer : - <input type="number" pattern="^(\s*\d*[02468]\s*,)*(\s*\d*[-2-4-6-8]\s*)$">

Q10) Write a JavaScript function that has two arguments, multiplies them and returns the result. Invoke the function and then print the result using alert.

Answer: -

<script>
function myFunction() {

var y = 6;
var z = 6;
var x = y * z;
  alert("The Result is " + x);

}

</script>

Q11) Use the getElementById method to find the <p> element, and change its text to "Hello":

Answer : -

<p id="demo"></p>
<script>
 document.getElementById("demo").innerHTML="Hello";
</script>

Please do not forget to appreciate my work by hitting that like or thumbs-up button, it really motivates me<3

Thank you!!


Related Solutions

Discuss the thresholds that trigger the need for an item of capital expenditure. What information would...
Discuss the thresholds that trigger the need for an item of capital expenditure. What information would you need to provide for the approval process? Why?
SQL- Trigger I have two tables (below) I need to write a trigger that would delete...
SQL- Trigger I have two tables (below) I need to write a trigger that would delete everything for a pid from the Appt table if the pid is deleted from the patient table. Create table Appt(                 pid numeric Foreign Key references patient(pid),                 ptname varchar(50) Foreign Key references patient(name),                 dob date Foreign Key references patient(dob),                 dr varchar(20),                 appdate date,                 apptime time, ); and Create table Patient(                 pid numeric primary key,                 name varchar(50),                ...
what kind of information does a health care organization need to function smoothly?
what kind of information does a health care organization need to function smoothly?
Based on your experience of MYOB, what can be replaced and what cannot be replaced by the AIS?
Based on your experience of MYOB, what can be replaced and what cannot be replaced by the AIS?  
What does a drug need to be soluble in water? What does a drug need to...
What does a drug need to be soluble in water? What does a drug need to be permeable to tissues? What will happen if the solubility of my drug changes over time?
What is the function (what is it, what does it do, how does it do it)...
What is the function (what is it, what does it do, how does it do it) of a defrost high limit thermostat and a defrost termination thermostat?
Why does the healthcare field need specially trained managers to properly function? How does a healthcare...
Why does the healthcare field need specially trained managers to properly function? How does a healthcare manager differ from any other manager in another field?
What does it mean to overload a function? What are the requirements?
What does it mean to overload a function? What are the requirements? Give an example of 2 overloaded functions.
What is a [cumulative] distribution function and what does it describe?
What is a [cumulative] distribution function and what does it describe?
What is the function of the "reticular formation?" What does it regulate? What is "oxytocin?" What does it do?
 1. What is the function of the "reticular formation?" What does it regulate? 2. What is "oxytocin?" What does it do?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT