2011-08-08 3 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のメッセージについて何かを読んでください。