|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Smurf Join Date: Jan 2008
Posts: 2
![]() | Hi, I'm having a bit of problem with my javascript program that i am creating. If the user inputs 1 into the dialogue box it sets up a new customer account, where the user is prompted to input their forename, surname, and a password of their own choice. when the customer has entered these details, the program allocates a customer code (first letter of first name, and first letter of last name, followed by a dash). the program should then display a welcome message, followed by the customer code, customers first name, surname and password. Now the password should only display the first and last characters, and all other characters in between should be replaced by an asterisk. however i can not make the password do this. please can someone help me with this problem. thanks <HTML> <HEAD> M150 TMAO3 Question 1<BR> <TITLE>SOFASPEND - IN THE BEST POSSIBLE TASTE!</TITLE> <SCRIPT language="JavaScript" type="text/javascript"> function checkLength(aString) { return (aString.length >= 7) && (aString.length <= 15) }; function doChecks(password) { var errorFound; errorFound = false; if (!checkLength(password)) { errorFound = true; window.alert( 'Your chosen password length is not in range of (7-15) characters.') }; if (!errorFound) { window.alert('Your password has been accepted.') document.write('<BR>' + 'First name: ' + forename); document.write('<BR>' + 'Last name: ' + surname); document.write('<BR>' + 'Customer Code: ' + forename.charAt(0) + surname.charAt(0) + '-'); document.write('<BR>' + 'Password: ' + passwordString); }; return errorFound } var enter; // display dialogue box to either set up a new account or to login var forename; var surname; var errorFound = false; var passwordString; enter = window.prompt('Please enter 1 to set up a new account, or 2 to login.',''); // dialogue box appears if (enter == '1') // value of 1 to be entered to set up a new account { document.write('<BR> WELCOME - WE WILL SET UP YOUR ACCOUNT DETAILS NOW <BR>') // displays msg if value of 1 has been entered { forename = window.prompt('Please enter your first name.',''); surname = window.prompt('Please enter your surname.',''); passwordString = window.prompt('Please enter a password of your choice.',''); errorFound = doChecks(passwordString); while (errorFound == true) { passwordString = window.prompt('Please re-enter a password of your choice.',''); errorFound = doChecks(passwordString) } } } else { if (enter == '2') // value of 2 to be entered to login as an existing customer { document.write('<BR> SHOP UNTIL YOU DROP <BR>') // displays msg if value of 2 has been entered } else { enter = window.prompt('Please re-enter either 1 or 2.',''); // dialogue box appears if wrong value entered if (enter == '1') // value of 1 to be entered again to set up a new account { document.write('<BR> WELCOME - WE WILL SET UP YOUR ACCOUNT DETAILS NOW <BR>') // displays msg if value of 1 has been entered within the loop { forename = window.prompt('Please enter your first name.',''); surname = window.prompt('Please enter your surname.',''); passwordString = window.prompt('Please enter a password of your choice.',''); errorFound = doChecks(passwordString); while (errorFound == true) { passwordString = window.prompt('Please re-enter a password of your choice.',''); errorFound = doChecks(passwordString) } } } else { if (enter == '2') // value of 2 to be entered again to login as an existing customer { document.write('<BR> SHOP UNTIL YOU DROP <BR>') // displays msg if value of 2 has been entered within the loop } else { enter = window.prompt('Please re-enter either 1 or 2.',''); // dialogue box appears if wrong value entered within the loop if (enter == '1') // value of 1 to be entered again to set up a new account { document.write('<BR> WELCOME - WE WILL SET UP YOUR ACCOUNT DETAILS NOW <BR>') // displays msg if value of 1 has been entered within the loop { forename = window.prompt('Please enter your first name.',''); surname = window.prompt('Please enter your surname.',''); passwordString = window.prompt('Please enter a password of your choice.',''); errorFound = doChecks(passwordString); while (errorFound == true) { passwordString = window.prompt('Please re-enter a password of your choice.',''); errorFound = doChecks(passwordString) } } } else { if (enter == '2') // value of 2 to be entered again to login as an existing customer { document.write('<BR> SHOP UNTIL YOU DROP <BR>') // displays msg if value of 2 has been entered within the loop } } } } } } </SCRIPT> </HEAD> <BODY> </BODY> </HTML> |
| | |
|
| |||||||
| | #2 |
| Smurf Join Date: Jan 2008
Posts: 2
![]() | Just to let you know what i'm after. when the browser displays the customers details the password should look this: Password: C*********e |
| | |
| | #3 |
| Smurf Join Date: Jan 2008
Posts: 1
![]() | I'm not exactly sure of the syntax of Javascript but what you need to do is: function ReturnObsficated(password) { var iPassLength = password.length; var i = 0; var ReturnString; while(i<=iPassLength) { if ((i==0)||(i==iPassLength) { ReturnString(i)=password(i); } else { ReturnString(i)='*'; } i = i + 1; } return ReturnString; } I think that may work but am trying to apply c++ to js, which is a recipe to disaster. Anyway try that and see if it works. |
| | |
| | #4 |
| Smurf Join Date: Jan 2008
Posts: 10
![]() | Can't right now, but I'll see if I can have a look at it later. |
| | |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|