2014-09-01 105 views
0

我学习jQuery验证从>>http://bassistance.de/jquery-plugins/jquery-plugin-validation/。我设置自定义消息内嵌HTML,这样自定义消息通过HTML jquery验证没有显示

<input name="pelatihan_performance" type="radio" value="1" required /> 
<input name="pelatihan_performance" type="radio" value="2" /> 
<input name="pelatihan_performance" type="radio" value="3" /> 
<input name="pelatihan_performance" type="radio" value="4" /> 
<input name="pelatihan_performance" type="radio" value="5" /> 

// error handler 
<label for="pelatihan_performance" class="error">Harap pilih Kinerja</label> 

但是当我运行这段代码,错误只显示“这是必须填写”不“Harap pilih Kinerja”。如何解决它?

+1

尝试'' – 2014-09-01 03:51:45

+0

oh谢谢您:) – 2014-09-01 03:57:39

回答

1

添加自定义的信息您可以通过使用data-msg-属性自定义消息像

<input name="pelatihan_performance" type="radio" value="1" required data-msg-required="Harap pilih Kinerja"/> 

演示:Fiddle

还是要放置错误消息在特定的地方,您可能要覆盖errorPlacement选项

0

您可以通过规则

$('#form').validate({ 
    rules: { 
     pelatihan_performance: { 
      required : true 
     } 
    }, 
    messages: { 
     pelatihan_performance: "Harap pilih kinerja" 
    } 
}); 
+0

我想要inline html sir ..但谢谢你的回答:) – 2014-09-01 03:58:21