Question
Can someone tell me why the input validation does not work in my code please? Discount Calculator Price: Discount: % Calculate discount Total After Discount:
Can someone tell me why the input validation does not work in my code please?
Discount Calculator
%
function calcDiscount()
{
var price = document.getElementById("price").value;
var discount = document.getElementById("discount").value;
var totalValue = price - ( price * discount/100 );
document.getElementById("total").value = totalValue;
}
function validate_input ( )
{
valid = true;
if ( input.price == "" )
{
alert ( "Please fill in the Price box." );
valid = false;
}
return valid;
}
function validate_input ( )
{
valid = true;
if ( input.discount == "" )
{
alert ( "Please fill in the Discount box." );
valid = false;
}
return valid;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started