а

login form


#1

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?


#2

Please see attached demo.
33.zip (27.7 KB)


#3

i get: out of memory at line 1096?


#4

Works fine on our side.

Please provide more details on error.


#5

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”);
}
});
}

});



}

#6

Who throws error? Client or server side?


#7

client i assume, when i open the server file in the browser:
server?login=admin&pwd=1 i get good, so thats working?


#8

Could you please provide direct link to view issue?


#9

link removed


#10

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
		...
	}
}

#11

thnx for the help!


#12

now i get, xml is not defined?
dhtmlxforms.js on rule 997 char 18

how can i define it?


#13

Known form’s bug, previously attached demo contain fixed dhtmlxform.js


#14

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>';


#15

what do you mean?
make what?


#16

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"} ];


#17

it gives a javascript error: ‘xml’ is not defined on dhtmlxform.js row: 997 char: 18


#18

try attached file
dhtmlxform.js.zip (13.8 KB)


#19

now it doesnt even load the form anymore (the structure … loadStruct )


#20

please send us your demo when “xml is not defined”
or just add function(xml…) manualy into code