2011-08-08 43 views
-2

我正在注册表单上,我想在twitter上验证用户名。有人可以给我一些提示,在那里我可以开始,有类似的已经工作实时验证

非常感谢您对我们的关注的东西

回答

0

模板:

<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>) 
    ) 
) 

上面的代码应该可以工作,但我不确定(我复制了更大的应用程序的一部分)。您应该查看Lift API中的SHtml.textAjaxTest方法并阅读有关Lift中消息的内容。