Skip to content

Commit

Permalink
Added jsdoc comments to explain the new API for providing custom erro…
Browse files Browse the repository at this point in the history
…r messages from an ajax test.
  • Loading branch information
micmath committed Jul 15, 2009
1 parent 1134ebf commit 4cf3c38
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/forms/forms.js
Expand Up @@ -707,21 +707,26 @@ glow.forms.tests = {
'arg' is the function to handle the response from the server.
This function should return a truthy value to indicate whether the server
response should be considered a PASS or a FAIL. Optionally you can include a bespoke
error message by returning an array of two elements, the first being
the PASS or FAIL verdict, and the second being the error message to display.
'url' is the url to call. You can use placeholders in here for form values (see example).
@example
function handleResponseText(response) {
if (response.text() == "OK") {
return glow.forms.PASS;
} else {
return glow.forms.FAIL;
}
}
myForm.addTests(
"username",
["ajax", {
arg: handleResponseText,
url: "/cgi/checkname.cgi?name={username}"
url: "/cgi/checkname.cgi?name={username}",
arg: function (response) {
if (response.text() == "OK") {
return glow.forms.PASS;
} else {
return [glow.forms.FAIL, "That name is already taken."];
}
},
message: "The server responded: that name is not permitted."
}]
);
*/
Expand Down

0 comments on commit 4cf3c38

Please sign in to comment.