Thanks with the book. Is a really great book ;)
But i have a problem with "IncrementalFieldValidation.
js"
With this code you can controll only one textfield.
But what is when i have 2 textfields with two Buttons?
////// Test ////// Buttton (disabled)
///// Alex /////// Button (available)
The problem is with the code from "IncrementalFieldValidation.
js" controll both txtfields and buttons :( This means when i type a correct string into one textfield then both buttons are available. What must i change?
Code of IncrementalFieldValidation.
js:
//Ajax
var oXmlHttp = null;
var iTimeoutId = null;
//function to validate fields
function validateField(oEvent) {
oEvent = oEvent || window.event;
var txtField = oEvent.target || oEvent.srcElement;
var btnNextTest = document.getElementById("btnNextTest");
var btnNextTest1 = document.getElementById("btnNextTest1");;
btnNextTest.disabled = true;
btnNextTest1.disabled = true;
if (iTimeoutId != null) {
clearTimeout(iTimeoutId);
iTimeoutId = null;
}
if (!oXmlHttp) {
oXmlHttp = zXmlHttp.createRequest();
} else if (oXmlHttp.readyState != 0) {
oXmlHttp.abort();
}
oXmlHttp.open("get", "includes/checkingForm.php?" + txtField.name + "=" + encodeURIComponent(txtField.value), true);
oXmlHttp.onreadystatechange = function () {
if (oXmlHttp.readyState == 4) {
if (oXmlHttp.status == 200) {
var arrInfo = oXmlHttp.responseText.split("||");
var imgError = document.getElementById("img" + txtField.id.substring(3) + "Error");
if (!eval(arrInfo[0])) {
imgError.title = arrInfo[1];
imgError.style.display = "";
txtField.valid = false;
} else {
imgError.style.display = "none";
txtField.valid = true;
}
btnNextTest.disabled = !txtField.valid;
btnNextTest1.disabled = !txtField.valid;
} else {
alert("An error occurred while trying to contact the server.");
}
}
};
iTimeoutId = setTimeout(function () {
oXmlHttp.send(null);
}, 500);
};[/code]
and the onload file:
Code:
window.onload = function () {
if (zXmlHttp.isSupported()) {
var btnNextTest = document.getElementById("btnNextS");
var btnNextTest1 = document.getElementById("btnNextSp");
var txtTest = document.getElementById("txtTest");
var txtTest1 = document.getElementById("txtTest1");
btnNextTest.disabled = true;
btnNextTest1.disabled = true;
txtTest.onkeyup = validateField;
txtTest.onchange = validateField;
txtTest1.onkeyup = validateField;
txtTest1.onchange = validateField;
txtTest.valid = false;
txtTest1.valid = false;
}
};
Hope this is the correct forum and you can help me
Greetings
Berliner