Question

I need help solving these problems using JavaScript coding i want to know the proper codes...

I need help solving these problems using JavaScript coding i want to know the proper codes for this problem using Javascript

Need help solving these two problems

  1. Create a pseudocode program that creates a form and asks the user to enter the date in the format mm/dd/yy. Validate the form to ensure the date was entered correctly.
  2. Convert the pseudocode in question one to JavaScript and test your program

0 0
Add a comment Improve this question Transcribed image text
Answer #1

==================================================================

<!DOCTYPE html>
<html>
<body>

<form id="frm1" action="#" onsubmit="return myFunction();">
Enter Date: <input type="text" id="myDate" value=""><br><br>
<input type="submit" value="Submit">
</form>

<script>

function maxDaysInMonth(m, y) {
switch (m) {
case 2 :
return (y % 4 == 0 && y % 100) || y % 400 == 0 ? 29 : 28;
case 9 :
case 4 :
case 6 :
case 11 :
return 30;
default :
return 31
}
}

function isValidDate(d, m, y) {
return d > 0 && d <= maxDaysInMonth(m, y) && m > 0 && m <= 12 ;
}


function myFunction() {
var myDate = document.getElementById("myDate").value;
var tokens = myDate.split("/");
  
if(tokens.length != 3 || isNaN(tokens[0]) || isNaN(tokens[1]) || isNaN(tokens[2]) || (tokens[0].length != 2) || (tokens[1].length != 2) || (tokens[2].length != 2)) {
alert('Invalid date');
} else {
var m = parseInt(tokens[0]);
   var d = parseInt(tokens[1]);
   var y = parseInt(tokens[2]);

console.log(m + " " + d + " " + y);

if(!isValidDate(d, m, y)) {
alert('Invalid date');
} else {
alert('Valid date');
}
}
  
return false;
}
</script>

</body>
</html>

Add a comment
Know the answer?
Add Answer to:
I need help solving these problems using JavaScript coding i want to know the proper codes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help solving these 2 problems using JavaScript coding 1. A sales agent is paid...

    I need help solving these 2 problems using JavaScript coding 1. A sales agent is paid commission on sales. If she sells 200 products per month, she receives a commission of 10%. If she sells more than 200 products but less than 350, she receives a commission of 15 %. If she sells more than 350 products per month, she receives a commission of 20%. Using pseudocode, create an algorithm for the sales agent. Develop a JavaScript program based on...

  • PYTHON CODING HELP: BELOW ARE THE STEPS I NEED HELP WITH PLEASE. :) First create a...

    PYTHON CODING HELP: BELOW ARE THE STEPS I NEED HELP WITH PLEASE. :) First create a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots ... and have it be in the same directory as the Python program you are coding for this assignment. IMPORTANT: Your program should work with any size file. It should work with 100 items listed or with no items in the file! Write a Python program that ... 1....

  • Hey guys. I am new to coding. And I need your help in answering this problem...

    Hey guys. I am new to coding. And I need your help in answering this problem for me. You have to answer this problem using only C++ programming language. Thanks. "Write a program that asks the user for an integer value, num. The program calculates the total number of factors of num. For example, if the user enters 12, the program should print out 6 (1,2,3,4,6,12)."

  • Need any help I can get solving this problem. I just started coding less than a...

    Need any help I can get solving this problem. I just started coding less than a month ago. A) Woody Furniture Sales The Woody Furniture Company sells several types of styles of chairs. Write a program that will take from the keyboard input • name of a chair style, • number of chairs sold of that style, • price of each chair of that style. Do this for three chairs (do not use loops i.e. you will need three chair...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • I know it seems like a lot of problems but i really need help solving them!...

    I know it seems like a lot of problems but i really need help solving them! Thanks! Draw resonance contributors for the following species. Indicate which are major contributors and which are minor contributors to the resonance hybrid. Do any of the species have resonance contributors that all contribute equally to the resonance hybrid?

  • I need help solving problem 9.16 from matlab for engineers holly moore 4th edition % 9.16...

    I need help solving problem 9.16 from matlab for engineers holly moore 4th edition % 9.16 A store owner asks you to write a program for use in the checkout process. % The program should: % • Prompt the user to enter the cost of the first item. % • Continue to prompt for additional items, until the user enters 0. % • Display the total. % • Prompt for the dollar amount the customer submits as payment. % •...

  • I need help with solving this step by step, please help me solve these step by...

    I need help with solving this step by step, please help me solve these step by step and with explanation, please do It on paper and not typed up because it is really confusing when typed up format and your Solve the following problems. Your solutions should be in the final answers should have the correct units and number of significant figures. 58. proper What mass of Mg(OH), will dissolve in 1.0 L of 0.050 mol/L solution of MgSO4a? (9...

  • PSEUDOCODE HELP i need for this to be in the most basic form of pseudocode. thanks...

    PSEUDOCODE HELP i need for this to be in the most basic form of pseudocode. thanks for your time. Create the logic for an application that contains an array of 10 multiple-choice questions related to your favorite hobby. Each question contains three answer choices. Also create a parallel array that holds the correct answer to each question—A, B, or C. Display each question and verify that the user enters only A, B, or C as the answer—if not, keep prompting...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT