Опытный | Всем доброй ночи. Столкнулся с проблемой. На сайте есть форма обратной связи(всплывающее окно), при заполнении обоих полей нажимаю кнопку отправить и форма пишет что заполнены не все поля, хотя это не так. Ниже код:
Код HTML: <script text="javascript">
{literal}
$('document').ready(function(){
$('#send_friend_button').fancybox({
autoScale : true,
'hideOnContentClick': false
});
$('#sendEmail').click(function(){
var datas = [];
$('#fancybox-content').find('input').each(function(index){
var o = {};
o.key = $(this).attr('name');
o.value = $(this).val();
if (o.value != '')
datas.push(o);
});
if (datas.length >= 3)
{
$.ajax({
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
type: "POST",
headers: {"cache-control": "no-cache"},
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', friend: unescape(JSON.stringify(datas).replace(/u/g, '%u'))},{/literal}{literal}
dataType: "json",
success: function(result){
$.fancybox.close();
}
});
}
else
$('#send_friend_form_error').text("{/literal}{l s='You did not fill required fields' mod='sendtoafriend' js=1}{literal}");
});
});
{/literal}
</script> <li class="sendtofriend"> <a id="send_friend_button" href="#send_friend_form"><i class="icon-envelope"></i>{l s='Send to a friend' mod='sendtoafriend'}</a> </li> <div style="display: none;"> <div id="send_friend_form"> <h1 class="title clearfix">{l s='Send to a friend' mod='sendtoafriend'}</h1> <div class="row-fluid"> <div class="span6 titled_box"> <h2 class="product_name"><span>{$stf_product->name}</span></h2> <div class="product clearfix"> <img src="{$link->getImageLink($stf_product->link_rewrite, $stf_product_cover, 'small_default')}" alt="{$stf_product->name|escape:html:'UTF-8'}" /> <div class="product_desc">
{$stf_product->description_short}
</div> </div> </div> <div class="span6"> <div class="send_friend_form_content"> <div id="send_friend_form_error"></div> <div class="form_container titled_box"> <h2 class="intro_form "><span>{l s='Recipient' mod='sendtoafriend'} :</span></h2> <p class="text"> <label for="friend_name">{l s='Name of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label> <input id="friend_name" name="friend_name" type="text" value=""/> </p> <p class="text"> <label for="friend_email">{l s='E-mail address of your friend' mod='sendtoafriend'} <sup class="required">*</sup> :</label> <input id="friend_email" name="friend_email" type="text" value=""/> </p> <p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p> </div> </div> </div> </div> <p class="submit sendfrend_footer"> <input id="id_product_comment_send" name="id_product" type="hidden" value="{$stf_product->id}" /> <button class="btn btn-inverse" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</button> <button id="sendEmail" class="btn btn-inverse" name="sendEmail" type="submit" />{l s='Send' mod='sendtoafriend'}</button> <!-- input id="sendEmail" class="btn btn-inverse" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" / --> </p> </div> </div> так вот вопрос: почему форма пишет что не все заполнено? |