Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c115863
commit 372996c
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/views/examples/server_validation_with_updater.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script type="text/javascript" src="/javascripts/server_validation_with_updater.js"></script> | ||
|
||
<h2>Server-Side Validation</h2> | ||
|
||
<form> | ||
<table> | ||
<tr> | ||
<td>What is your name?</td> | ||
<td><input type="text" id="name"/></td> | ||
<td id="name_validation"> </td> | ||
</tr> | ||
<tr> | ||
<td>What is your favorite color?</td> | ||
<td><input type="text" id="favorite_color"/></td> | ||
<td id="favorite_color_validation"> </td> | ||
</tr> | ||
</table> | ||
</form> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
document.observe("dom:loaded", function() { | ||
$("name", "favorite_color").invoke("observe", "change", function(item) { | ||
var elem = item.element(); | ||
console.log(elem); | ||
new Ajax.Updater(elem.id + "_validation", "/examples/validate_field", { | ||
method: 'post', | ||
parameters: {field: elem.id, value: elem.value}, | ||
onFailure: function(req) {alert(req.responseText)}, | ||
onException: function(t,e) {alert(e);} | ||
}); | ||
}); | ||
}); |