我正在使用表单。当用户转到我的页面时,使用css和display:none属性隐藏了一些表单字段。显示的唯一字段是链接,图像和文本区域。我试图在用户单击链接时向用户显示表单的其余部分,但仅当文本区域少于1000个字符时才显示。
#promotion_image_description_block 是textarea ID #promotion 是链接的href。
的JavaScript
<script type="text/javascript">
$(function () {
$('a[href^="#"]').click(function (e) {
if ($("#promotion_image_description_block").val().length >= 1000) {
alert("This must be less than 1000 Characters!");
return false;
} else {
switch ($(this).attr('href')) {
case '#promotion':
$('#promotion_facebook_id_block, #promotion_name_block, #promotion_email_block, #promotion_address_1_block, #promotion_csz_block, #promotion_country_block, #promotion_phone_block, #promotion_custom_field_9_block, #promotion_custom_field_8_block, #promotion_custom_field_4_block, #promotion_custom_field_2_block, #promotion_custom_field_5_block, #promotion_custom_field_6_block, #promotion_custom_field_3_block, #promotion_agree_block, #promotion_submit_block, #disclaimer_promotion, #links2').show();
$('#promotion_custom_field_10_block, #promotion_image_description_block, #promotion_custom_field_11_block').hide();
e.preventDefault();
break;
}
}
});
});
</script>
此修复程序显示警告: