live validation
I'm working on a signup form, and I want to live a validation of the user name as on twitter. Someone can give me some tips where I can start, there is s开发者_Go百科omething similar already worked
Thank you very much for your attention
Template:
<test:name/><div id="message">
Snippet:
// helper function, returns function which checks if given string is not-empty
// and then returns JS with error message
def notEmpty(anchor: String, message: NodeSeq): String => JsCmd = text =>
if (text.isEmpty) DisplayMessage(anchor, message, 5 seconds, 1 second) else Noop
bind("test", template,
"name" -> SHtml.textAjaxTest(
"initial value",
(s:String) => logger.debug("Value changed to: %s".format(s))
notEmpty("message", <b>Name must not be empty</b>)
)
)
Above code should work, but I'm not sure (I copied part of bigger application). You should look at SHtml.textAjaxTest
method in Lift API and read something about messages in Lift.
精彩评论