how can i use the form to build a login script?
i want to use the validate funtion to check if the username and password match, but how can i do this?
i get: out of memory at line 1096?
Works fine on our side.
Please provide more details on error.
i’m loading the form into a window with attachform, that might cause it?
var inloggenform = [
{type: “label”, label: “Vul uw gebruikersnaam en wachtwoord in.”},
{type: “input”, label: “Gebruikersnaam”, validate: “NotEmpty”},
{type: “password”, label: “Wachtwoord”, validate: “NotEmpty”},
{type: “checkbox”, label: “Onthoud mijn gegevens”, checked: false},
{type: “button”, command: “validate”, value: “Inloggen”}
];
var InlogForm = dhxWins.window(id).attachForm(inloggenform);
InlogForm.attachEvent(“onAfterValidate”, function (id, result)
{
if (result == true)
{
InlogForm.send(“server.php?etc=”+new Date().getTime(), “get”, function(response){
if (response.xmlDoc.responseText == “good”) {
alert (“Login successful”);
} else {
alert (“Login failed”);
}
});
}
});
}
Who throws error? Client or server side?
client i assume, when i open the server file in the browser:
server?login=admin&pwd=1 i get good, so thats working?
Could you please provide direct link to view issue?
link removed
The problem is:
Method “send” calls “validate” before sending data. You’re calling “send” inside “onAfterValidate”, so you have unend recursion.
So you have: button click->validate->afterValidate event->send->send’s validate->afterValidate event->send->send’s validate…
Solution:
Add button with custom command (not validate and not send), attach onButtonClick event and call “send” only (it will automaticaly validate data).
var inloggenform = [
...
{type: "button", command: "doLogin", value: "Inloggen"}
];
...
InlogForm.attachEvent("onButtonClick", function (name, cmd) {
if (cmd == "doLogin") {
InlogForm.send(...); // "validate" will called automaticaly
...
}
}
thnx for the help!
now i get, xml is not defined?
dhtmlxforms.js on rule 997 char 18
how can i define it?
Known form’s bug, previously attached demo contain fixed dhtmlxform.js
how can i make this when i load the form in with xml?
var dhxLogin = dhxWins.window(id).attachForm();
dhxLogin.loadStruct("inc/xml/formulieren/inloggen.php");
dhxLogin.attachEvent("onButtonClick", function (name, cmd)
{
if (cmd == "doLogin")
{
dhxLogin.send("inc/inloggen.php?etc="+new Date().getTime(), "get", function(response)
{
alert('test');
var checkok = response.xmlDoc.responseText;
var rowsOK = checkok.split("-");
if (rowsOK[0] == "good")
{
var username = rowsOK[1]; parent.dhxWins.window("userWin1").close();
document.location.reload();
}
else
{
alert("Onjuiste inlog gegevens.");
}
});
}
});
the form looks like this:
echo '<items>';
echo '<item type="label" label="Vul uw gebruikersnaam en wachtwoord in."/>';
echo '<item type="input" name="login" label="Gebruikersnaam" validate="NotEmpty"/>';
echo '<item type="password" name="pwd" label="Wachtwoord" validate="NotEmpty"/>';
echo '<item type="checkbox" label="Onthoud mijn gegevens" checked="false"/>';
echo '<item type="button" command="doLogin" value="Inloggen"/>';
echo '</items>';
what do you mean?
make what?
when i use the loadstruct:
var dhxLogin = dhxWins.window(id).attachForm();
dhxLogin.loadStruct("inc/xml/formulieren/inloggen.php");
this doestnt work anymore:
dhxLogin.send("inc/inloggen.php?etc="+new Date().getTime(), "get", function(response)
{
check = response.xmlDoc.responseText;
// do something
}
it did work when i attached the form with:
var InlogForm = dhxWins.window(id).attachForm(inloggenform);
var inloggenform = [
{type: "label", label: "Vul uw gebruikersnaam en wachtwoord in."},
{type: "input", name: "login", label: "Gebruikersnaam", validate: "NotEmpty"},
{type: "password", name: "pwd", label: "Wachtwoord", validate: "NotEmpty"},
{type: "checkbox", label: "Onthoud mijn gegevens", checked: false},
{type: "button", command: "doLogin", value: "Inloggen"}
];
it gives a javascript error: ‘xml’ is not defined on dhtmlxform.js row: 997 char: 18
now it doesnt even load the form anymore (the structure … loadStruct )
please send us your demo when “xml is not defined”
or just add function(xml…) manualy into code