Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > HTML > JavaScript
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Reply
 
Thread Tools Search this Thread Display Modes
Old 01-04-2008, 11:41 AM   #1
stew2508
Smurf
 
stew2508's Avatar
 
Join Date: Jan 2008
Posts: 2
stew2508 is on a distinguished road
Default Please can someone help

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>
stew2508 is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 01-05-2008, 02:29 PM   #2
stew2508
Smurf
 
stew2508's Avatar
 
Join Date: Jan 2008
Posts: 2
stew2508 is on a distinguished road
Default Re: Please can someone help

Just to let you know what i'm after. when the browser displays the customers details the password should look this:

Password: C*********e
stew2508 is offline   Reply With Quote
Old 01-17-2008, 01:18 PM   #3
OsirisWireless
Smurf
 
OsirisWireless's Avatar
 
Join Date: Jan 2008
Posts: 1
OsirisWireless is on a distinguished road
Default Re: Please can someone help

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.
OsirisWireless is offline   Reply With Quote
Old 01-17-2008, 06:47 PM   #4
runehero123
Smurf
 
runehero123's Avatar
 
Join Date: Jan 2008
Posts: 10
runehero123 is on a distinguished road
Default Re: Please can someone help

Can't right now, but I'll see if I can have a look at it later.
runehero123 is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Reply



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump


All times are GMT. The time now is 06:33 AM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.