Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form validation

Status
Not open for further replies.

riches85

Programmer
Nov 13, 2002
59
US
I have a form that users can add user information into the database. I have some javascript that checks to make sure that all of the values have been entered before they are submitted, but I would like to take it one step farther. I would also like it to be able to look and see if the users email address is already in the database before the form data is entered. This would involve accessing mysql through javascript. I am at a loss as to how to go about and do this so I was wondering if someone would be able to point me in the right direction. Here is the validation code so far.

function checkInputs (form) {

if (form.userName.value == "") {
alert ("You must provide a username!");
form.userName.focus ();
return false;
}

if (form.password.value != form.pass_verify.value) {
alert ("Your passwords do not match!");
form.password.focus ();
return false;
}

if (form.email.value == "") {
alert ("You forgot to enter your email address!");
form.userName.focus ();
return false;
}

if (form.fullName.value == "") {
alert ("You forgot to enter your Full Name!");
form.password.focus ();
return false;
}
return true;
}
 
"This would involve accessing mysql through javascript." This cannot be done because Javascript is a client-side programming language. However what you can do is implement a server side validation not client-side. Write a query in your processing page that will compare the value that is entered with the value that is already stored in the database. If the query returns a value then you skip inserting values to the table and dislay a message on a window saying that a duplicate record has been found,etc.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top