Calculating a username from first and last name input fields

admin

Administrator
Staff member
FYI: this is my first post to this forum.

By setting the onchange event for form text input tags name=firstname, and name=lastname to setuname() I wish to calculate a username being the first char of the firstname and first 5 chars of the lastname fields. Both input tags f and l names are text.

Basically, this javascript is incorrect. Could someone assist with the correct syntax.

<SCRIPT language="JavaScript">
function setuname ()
{
var a = Left(document.myform.firstname.value, 1);
var b = Left(document.myform.lastname.value, 5);
document.myform.username.value = a+b;
}
</SCRIPT>

Many thanks - Dickey
 
Back
Top