Hi there,
I have two prompt dialogue boxes that ask the user the enter their name and their employee number.
I am experiencing two errors. The first is, if a user enters an employee number that is less than 6 digits, the program accepts the number, which it shouldn’t.
The second error is that the user is reminded only once to correct their error. If for example they enter a number when they are asked to enter a string. An error message will appear, but only once, and the second time through the program accepts whatever the user enters.
I’m very new at this and desperate to learn what I’m doing wrong. Can someone out there help me to clean up my code? I don’t want the user to get away with entering anything incorrectly.
PLEASE PLEASE HELP ?
[CODE]
<script type=”text/javascript”>
// prompt the employer the enter the employee name and number
var employName = prompt (“Please enter the employees’ name” , ” “);
if (isNaN(employName)) {
document.write(“You are enquiring about: ” +employName );
} else { (employName == null || !isNaN(employName))
employName = prompt (“Please enter a valid name in this field”);
document.write(“You are enquiring about: ” +employName) ; }
document.write(“</br>”);
var employNum = prompt (“Please enter the employees’ 6 digit employee number” , ” “);
employNum = parseInt(employNum); {
if (employNum.toPrecision(6)) {
document.write(“Employee Number: ” +employNum);
} else { (isNaN(employNum) || !(employNum.toPrecision(6)) )
employNum = prompt(“Enter a 6 digit employee number, using only whole numbers “, “”);
document.write(“Employee Number: ” +employNum); }
document.write(“</br>”);
}
</script>