Scala 实时验证

Scala 实时验证,scala,lift,Scala,Lift,我正在做一个注册表单,我想在twitter上验证用户名。有人可以给我一些建议,我可以从哪里开始,有一些类似的东西已经奏效了 非常感谢您的关注模板: <test:name/><div id="message"> 片段: // helper function, returns function which checks if given string is not-empty // and then returns JS with error message d

我正在做一个注册表单,我想在twitter上验证用户名。有人可以给我一些建议,我可以从哪里开始,有一些类似的东西已经奏效了

非常感谢您的关注

模板:

 <test:name/><div id="message">

片段:

 // 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>)
      )
 )
//helper函数,返回检查给定字符串是否为空的函数
//然后返回带有错误消息的JS
def notEmpty(锚点:String,消息:NodeSeq):String=>JsCmd=text=>
if(text.isEmpty)DisplayMessage(锚定,消息,5秒,1秒)else Noop
绑定(“测试”,模板,
“名称”->SHtml.textAjaxTest(
“初始值”,
(s:String)=>logger.debug(“值更改为:%s”。格式))
notEmpty(“消息”,名称不能为空)
)
)
上面的代码应该可以工作,但我不确定(我复制了更大应用程序的一部分)。您应该查看Lift API中的
SHtml.textAjaxTest
方法,并阅读一些关于Lift中消息的内容