Form Field Validation within Other Function
I'm trying to do form validation on both fields to make sure the fields are not blank and that they only allow numbers and periods. I want to return an error if it's blank or contains illegal characters.
So, there are tons of tutorials on the web on how to do this and I've read a ton. These cookie cutter tutorials do not fit 100% into what I'm doing.
Here's my code:
var salary = document.calculateBonus.salary.value;
var payout = document.calculateBonus.payout.value;
var answer = (salary * payout / 100);
answer = Math.round(answer * 20) / 20;
("Your Bonus is $" + answer);
<form id="calculateBonus" name="calculateBonus" method="post" action="">
<label for="salary">Your Annual Salary</label>
<input type="text" name="salary" id="salary" tabindex="1" />
<label for="percentPayout">% Bonus Payout</label>
<input type="text" name="payout" id="payout" tabindex="2" />
- - - - - - - - - - -
Thank you for any assistance/direction you can give me!