我有一個表單,我希望填寫所有字段。如果字段未填寫,我想顯示該字段的紅色背景和消息。如果輸入爲空,則發出警報
\$('#id_form').blur(function()
{
if($(this).val().length == 0) {
$(this).parents('p').addClass('warning');
}
print $q->start_form (-method => 'post', -action => "add.pl", -id => 'id_form');
print $q->legend({-class => "ui-widget-header ui-corner-all"},"");
print $q->input ({-id => 'name', -name => 'name',-type => 'text' , -size => 20, -style => ' margin-left:300 px' },"<br>");
我不確定這是正確的做法!
這段代碼會發生什麼? – happybuddha
不起作用。它是一樣的,如果它我不把它 – Armida
http://jquerybyexample.blogspot.com/2012/12/jquery-to-check-all-textboxes-empty.html – zod