Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Combine Form Fields

Posted 09 Mar 2004 18:27:41
1
has voted
09 Mar 2004 18:27:41 colin hart posted:
I have a form that I made where the user creates a username and password. the form ask for the visitors firstname, lastname and password. I want to have another field on there for username but have it auto populate with the first letter of the firstname followed by the lastname. i.e. Bob Barker, then the username should be bbarker.

any suggestions

Replies

Replied 10 Mar 2004 03:32:00
10 Mar 2004 03:32:00 Phil Shevlin replied:
Javascript

<pre id=code><font face=courier size=2 id=code>
&lt;script language="JavaScript" type="text/JavaScript"&gt;
function setUsername() {
var fname = document.form1.firstname.value;
var lname = document.form1.lastname.value;
var uname = fname.charAt(0) + lname;
document.form1.username.value = uname.toLowerCase();
}
&lt;/script&gt;
&lt;form name="form1" method="post" action=""&gt;
&lt;input name="firstname" type="text" id="firstname"&gt;
&lt;input name="lastname" type="text" id="lastname" onBlur="setUsername();"&gt;
&lt;input name="username" type="text" id="username"&gt;
&lt;/form
</font id=code></pre id=code>

might not be the most efficient way, but should be understandable.
Replied 10 Mar 2004 19:57:34
10 Mar 2004 19:57:34 colin hart replied:
AWESOME
thanks

Reply to this topic