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

HTML and JavaScript ~~Create a web page that will allow the user to enter their

ID: 3705250 • Letter: H

Question

HTML and JavaScript ~~Create a web page that will allow the user to enter their name, address, city, state, zip, and email address.  If the state isn't  IN, IL, or MI, an alert box will pop up and the form will not be submitted.  If a valid state is entered, have the data emailed to randomuser@isu.edu with a popup message that the data has been sent.I have the code but when I test in the browser it does not perform any action. What am I doing wrong?

I also need help with a second question if possible. here are the directions for this: Create a web page that will calculate a number raised to an exponent using a loop.  Your output should display the answer as "x raised to the ypower is z".  A data validation check should pop up an alert box that says "Sorry, this program cannot handle exponents less than one" and the calculation not be performed if the user enters an exponent less than one.  The function that calculates the answer must be located in the head area of the web page, it must be called from the body area, and it must pass the number and the exponent the user inputs as parameters to the function.  The calculation should take place when the user moves the mouse off a graphic image.  Do NOT use the Exponent function that is built into JavaScript. I have not started the code for this one.

<!DOCTYPE html>

<html>

<head>

<title>Application Example</title>

<script type="text/javascript" language="JavaScript">

<!--

function valNsub() {

var state = (document.info.state.value);

if ((state=="MI")||(state=="IL")||(state=="MI"))

{document.DE.submit()}

else

{window.alert("State must be IN, IL, or MI")}

}

//-->

</SCRIPT>

</head>

<body>

<p><font size="5">Application</font></p>

<form name="DE" method="POST" action="randomuser@isu.edu">

<p>First Name:&nbsp;<input type="text" name="FirstName" size="20"><br>

Address:&nbsp;<input type="text" name="address" size="20"><br>

City:&nbsp;<input type="text" name="city" size="20"><br>

State:&nbsp;<input type="text" name="state" id="state"size="20"><br>

Zip:&nbsp;<input type="text" name="zip" size="20"><br>

Sender's Email:&nbsp;<input type="text" name="semail" size="35"><br>

<br>

<input type="button" name="Send" value="Send">

</p>

</form>

</body>

</html>

Explanation / Answer

you can use following code for validations:

but for to submit mail you have to use java code , directly you cannot send to mail.you have to use mail.api

<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = document.forms["DE"]["state"].value;
if ((x!="IN")&&(x!="IL")&&(x!="MI")) {
alert("State must be IN, IL, or M");
return false;
  
}
</script>
</head>
<body>

<p><font size="5">Application</font></p>

<form name="DE" method="POST" action="randomuser@isu.edu">

<p>First Name:&nbsp;<input type="text" name="FirstName" size="20"><br>

Address:&nbsp;<input type="text" name="address" size="20"><br>

City:&nbsp;<input type="text" name="city" size="20"><br>

State:&nbsp;<input type="text" name="state" id="state"size="20"><br>

Zip:&nbsp;<input type="text" name="zip" size="20"><br>

Sender's Email:&nbsp;<input type="text" name="semail" size="35"><br>

<br>

<input type="submit" name="Send" value="Send">

</p>

</body>
</html>

Navigate



Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.