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...

  • 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 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...

  • Please help!! I need help with C++ and im using the program Atom. Q6 Write a...

    Please help!! I need help with C++ and im using the program Atom. Q6 Write a complete C++ program that does the following. 1. It asks the user to enter positive integers a and b that are each at most 100. 2. The 3. The program determines and prints the maximum entry in each column of the table. 4. The program then prints the smallest value among these maximum entries. For example, the following represents one run of the program....

  • I need html coding in notepad++ according to the requirments those are listed in the pictures....

    I need html coding in notepad++ according to the requirments those are listed in the pictures. The purpose of this assignment is to figure out the designing and development of HTML forms with CSS and interaction between users and forms by using the Javascript script language. Below Student Registration Form views some form inputs entered by users and shows in the form as a response. Resources: All posted class documents and lab practices will help to complete this assignment. Student...

  • PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from...

    PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from tony gaddis starting out with java book. I have included the screenshot of the problems for reference. I need HELP implementing these two problems TOGETHER. There should be TWO class files. One which has TWO methods (one to implement problem 8, and one to implement problem 9). The second class should consist of the MAIN program with the MAIN method which calls those methods....

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
ADVERTISEMENT