Hi frnds ....

I am trying to create a contact form in PHP , MySql .... In my form i have two 3 input fields n a Submit Button .....

1. Name
2. email
3. SecurityCode ( here user have to enter the captcha code )

m collecting all information frm user and if the captch code entered by the user is correct then the values will be entered into my database n emailed to some adress ....

Everything is working perfectly ....... But my problem is ...

I want to check these things before submitting the form ..

1. Name field is empty
2. User has entered a valid email
3. User has entered the correct Captcha code as shown in image

# If anything wrong i want to display the information n don't want submit or refresh the page....

# If everything is correct , then submit the form and do the actions ....

# I have searched in Google .... for some Ajax Validation ... But nothing is working perfectly n are too mess ....

# Can anyone tell me a simple solution or just an Idea for how to handle this ... please ...

6 Years
Discussion Span
Last Post by Kannan R

You can handle these checks on the client-site by Javascript.
Or you make a AJAX call to your server (which is actually a post to your server), your server is checking the input and returns the result. When the result is OK, your form can post the data. While writing I thought: this will become a very weird solution: don't build it.

Why won't you post it and check the input on the server?


There are loads of client-side validators out there. jQuery has a good few. Another simple one is YAV. Anyway, js hijacks the submit action and on validation either returns error messages or proceeds with the submit.

You MUST have server-side validation as js can be circumvented and forms can be spoofed.


Anyone have any ideas how to solve this issues using jQuery ... Please .....


I think that you can make it simpler by using the validation through Java Script.
You can assign a function to the submit button. Don't set the button type as a "submit" button. For example:

<form name="Form1">
<input type="text" name="F1">
<input type="button" onclick="Validate();" value="Submit">

Java Script:

<script language="JavaScript">
Votes + Comments
in high security mode internet explorer ignores javescript


you can solve the problem using javascript and ajax

<form name="Form1">
<input type="text" name="name">
<input type="text" name="email">
<input type="text" name="code">
<input type="button" onclick="Validate();" value="Submit">

function check(){
alert('Please enter a name');
return false;
}else if(document.forms.form1.email.value.length<=0){
alert('Please enter your email ID');
return false;

}else if(document.forms.form1.code.value.length<=0){
alert('Please enter the code');
return false;


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.