Form validation

admin

Administrator
Staff member
Hello,
i have a simply form.
The people should select a username.
But every username can only appear once.

I have found this form validation:

But theres a little problem.
Example: The username thats just in use ist: carlo

But when anyone inserts:
carlos
as username, thats O.K.
But this form validation says: Username just in use.

How can i change this validation?

Thanks a lot for the help.

Bye Carlo

<html>
<head>
<script LANGUAGE="JavaScript">

function VerifyUsername(username) {
var at_pos;
var pd_pos;
var sp_pos;
var em_len;

// Make sure there is a value
em_len = username.length;
if (em_len < 1) {
return -1;
}


// check for double username
sp_pos = username.indexOf("carlo", 0);
if (sp_pos != -1) {
return -2;
}
return 1;
}

function ValidateForm(form) {
var checkUsername;
checkUsername = VerifyUsername(form.username.value);
if (checkUsername < 0) {
if (checkUsername == -1) {
alert("Please insert an username.");
}
if (checkUsername == -2) {
alert("Username in use. Please select another.");


}
form.username.focus();
}

else
{ document.form.submit();
}
}
</script>
</head>
<form action="mailto:[email protected]" method="post" name="form">
Username: <input type="text" name="username" size="37"><p>
<input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit" name="B1" onClick="ValidateForm(this.form)"></form>
 
Back
Top