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 their name incorrectly, using numbers for example, there is an error message that asks the user to re-enter their name using a string. If the user ignores the error message and enters a number a second time, the program accepts the entry, which it shouldn't.
The second error has to do with the employee number prompt. The prompt asks the user to enter an employee number that is equal to 6 digits, the program however accepts any number, less than or greater than 6 digits, which it shouldn't.
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
<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>