this is my javascript for validation of a form .It works perfectly

<script type="text/javascript">
function validateForm()
{
var x=document.forms["contacts-form"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
  alert("Not a valid e-mail address");
return false;
  }
var x=document.forms["contacts-form"]["name"].value;
if (x==null || x==""||x=="Name:")
  {
  alert("First name must be filled out");
  return false;
  }
var y=document.forms["contacts-form"]["comment"].value;
if (y==null || y==""||y=="Message:")
  {
  alert("Message must be filled out");
  return false;
  }
}
</script>

Now i want to submit my form without reloading the page. So please help me to modify this code !!!!! I will be very thankful to you

My advice will be to use json and use the get method and set

Please tell me the code . i dont know javascript.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.