<!DOCTYPE html> <html> <head> <META CHARSET=\"UTF-8\"> <title></title> </head> <
ID: 3816735 • Letter: #
Question
<!DOCTYPE html>
<html>
<head>
<META CHARSET="UTF-8">
<title></title>
</head>
<body>
<form action="/formtest.php">
Customer name:
<input type="text" name="Customer">
<br><br>Address:
<input type="text" name="address">
<br><br>
<p>Payment Choices</p>
<input type="radio" name="payment" value="Visa" checked>
<label for="Visa"> Visa</label><br>
<input type="radio" name="payment" value="MasterCard">
<label for="MasterCard"> MasterCard</label><br>
<input type="radio" name="payment" value="AmericanExpress">
<label for="AmericanExpress"> AmericanExpress</label>
<br><br>
<input type="submit">
</form>
<FORM Name="myform">
<SELECT NAME="memoryItem" id="memoryItem">
<OPTION value="0">Select One Choice from List-Memory Upgrade</OPTION>
<OPTION value="49">8 GB add $49</OPTION>
<OPTION value="98">12 GB add $98</OPTION>
<OPTION value="159">16 GB add $159</OPTION>
</SELECT>
<SELECT NAME="hddItem" id="hddItem">
<OPTION value="0">Select One Choice from List-HDD Upgrade</OPTION>
<OPTION value="109">1 TB HD add $109</OPTION>
<OPTION value="150">1.5 TB HD add $150</OPTION>
<OPTION value="199">2 TB HD add $199</OPTION>
<OPTION value="299">250 GB SSD add $299</OPTION>
</SELECT>
<SELECT NAME="networkItem" id="networkItem">
<OPTION value="0">Select One Choice from List- Network Upgrade</OPTION>
<OPTION value="109">56K V90 or X2 Modem add $109</OPTION>
<OPTION value="79">10/100 NIC add $79</OPTION>
<OPTION value="279">Combo Modem and NIC add $279</OPTION>
</SELECT>
</FORM>
<button type="button">Calculate</button>
The new calculated price:<INPUT type="text" id="PicExtPrice" Size=8>
</body>
</html>
Question-Remove the JavaScript code to calculate the total price. If you used anything other than a plain text box for quantities, change the quantity inputs to type="text". (The goal of this part of the assignment is for you to use regular expressions to validate text.)
Question-Add JavaScript code to produce an error message and suppress submission of the form if any quantity field contains non-numeric data. (It's OK for a quantity to be empty, but if it's non-empty, it must have only numbers.) Add an action= attribute to your <form> tag to submit the form to http://weblab.kennesaw.edu/formtest.php. Test that the form is submitted correctly when the quantities are numeric or empty, and that an error message is produced otherwise. (Regular expressions are your friend. Anything that's not a digit is bad. What is the predefined class for non-digits?)
Add to your index page a link to your new order form.
As with the previous assignment, the goal is to learn to validate with JavaScript. The use of an input element with type "number" or anything similar will earn a zero on this part of the assignment. You must use JavaScript for the validation.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<META CHARSET="UTF-8">
<title></title>
<script>
function allnumeric(inputtxt)
{
var numbers = /^[0-9]+$/;
// For count_network
if(inputtxt.count_network.value.match(numbers) && inputtxt.count_memory.value.match(numbers) && inputtxt.count_hdd.value.match(numbers))
{
alert('Your Registration number has accepted....');
inputtxt.count_network.focus();
return true;
}
else
{
alert('Please input numeric characters only');
inputtxt.count_memory.focus();
return false;
}
}
</script>
</head>
<body>
<form name = "myform" action="/formtest.php">
Customer name:
<input type="text" name="Customer">
<br><br>Address:
<input type="text" name="address">
<br><br>
<p>Payment Choices</p>
<input type="radio" name="payment" value="Visa" checked>
<label for="Visa"> Visa</label><br>
<input type="radio" name="payment" value="MasterCard">
<label for="MasterCard"> MasterCard</label><br>
<input type="radio" name="payment" value="AmericanExpress">
<label for="AmericanExpress"> AmericanExpress</label>
<br><br>
<b> Enter quantity :-</b>
<br><br>
List-Memory Upgrade :- <input type="text" name="count_memory" id = "count_memory">
<br><br>
List-HDD Upgrade :- <input type="text" name="count_hdd" id = "count_hdd">
<br><br>
List- Network Upgrade :- <input type="text" name="count_network" id = "count_network">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.