esthera
12-28-2011, 12:23 PM
I am using the following validation routine
function savenotes() {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = xmlhttp.responseText.split("~");
alert(result[0])
if (result[0] == "1") {
// alert(result[1]);
alert("should return true");
valid = true;
}
else {
alert(result[1]);
valid = false;
}
}
}
var str = "ok";
var mypost = "check.asp"
// alert(mypost);
xmlhttp.open("GET", mypost, true);
xmlhttp.send();
return valid;
}
now where do I put the return so that it returns to my form if it's valid or not.
It doesn't seem to work to me and the form is always submitted
I am calling this with
<form method=post action=admin.asp onsubmit="return savenotes()">
function savenotes() {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = xmlhttp.responseText.split("~");
alert(result[0])
if (result[0] == "1") {
// alert(result[1]);
alert("should return true");
valid = true;
}
else {
alert(result[1]);
valid = false;
}
}
}
var str = "ok";
var mypost = "check.asp"
// alert(mypost);
xmlhttp.open("GET", mypost, true);
xmlhttp.send();
return valid;
}
now where do I put the return so that it returns to my form if it's valid or not.
It doesn't seem to work to me and the form is always submitted
I am calling this with
<form method=post action=admin.asp onsubmit="return savenotes()">