Флажок + проверка метки jquery

0

Как заставить работать ошибку сообщения в флажке + ярлык с помощью проверки jquery?

У меня есть этот код:

HTML

    <form id="myform">
 <input type="checkbox" id="term" name="term_1" /> 
   <label for="term">
      <div class="check"></div>
      Blabla Term.
   </label>
</form>
<a href="http://docs.jquery.com/Plugins/Validation" target="_blank"></a>

CSS

input[type="checkbox"] {
    display:none;
}
input[type="checkbox"] + label .check {
    display:inline-block;
    width:16px;
    height:16px;
    margin:-3px 4px 0 0;
    vertical-align:middle;
    cursor:pointer;
}

input[type="checkbox"] + label .check {background:url(http://www.1.ligapariurilor.ro/imagini/sprite/radio-sprite.png) left top no-repeat;}

input[type="checkbox"]:checked + label .check{
    background:url(http://www.1.ligapariurilor.ro/imagini/sprite/radio-sprite.png) -16px top no-repeat;
}

И jQuery не работает

$(document).ready(function () {

    $('#myform').validate({
        rules: {
            'term': {
                required: true
            }
        }
    });

});

Демо-ссылка: http://jsfiddle.net/AsuyC/17/

  • 0
    что ты пытаешься сделать здесь
  • 0
    Я пытаюсь поставить сообщение об ошибке, когда не проверено
Теги:

2 ответа

0

Наверное, вы имеете в виду

$(document).ready(function () {

    $('#myform').validate({
        rules: {
            '#term': {
                required: true
            }
        }
    }); 
});
  • 0
    Не работа.......
0

Я отправил ответ. Это также возможность для вашей проблемы. Если вы работаете на asp.net, вы можете использовать RequiredFieldValidator на вашем другом элементе управления, например, в следующем примере:

<tr>
<td>
<asp:RequiredFieldValidator runat=server
    ControlToValidate=txtName
    ErrorMessage="Identifier is required."> *
</asp:RequiredFieldValidator>
</td>
<td>User Identifier :</td>
<td><input type=text runat=server id=txtName></td>
</tr>

Для обязательных полей вы можете использовать свойство ValidationSummary, которое отображает "*" перед обязательными полями.

<asp:ValidationSummary runat=server
      headerText="there is error on this page/>

и не забывайте метод проверки:

public sub OnSubmit(source as Object, e as EventArgs)
    if Page.IsValid then
    ' Some code
    end if
end sub
  • 0
    Я использую WordPress. Можете ли вы показать мне демо на моем примере?
  • 0
    здесь у вас есть отличный образец: ramanisandeep.wordpress.com/2010/02/10/…
Показать ещё 2 комментария

Ещё вопросы

Сообщество Overcoder
Наверх
Меню