ile').text(''); $(this).hide(); $('#fdAttaUrl').val(''); }); $('#fdForm').submit(function(e) { e.preventDefault(); const name = $('#name').val().trim(); const email = $('#email').val().trim(); const phone = $('#mycall').val().trim(); const qty = $('#quantiy').val().trim(); const contentText = $('#saytext').val().trim(); if (!name) { alert('Please enter your name'); return false; } const phoneValid = phone && /^d{6,}$/.test(phone.replace(/D/g, '')); const emailValid = email && /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/.test(email); if (!phoneValid && !emailValid) { alert('Please enter either a valid phone number (at least 6 digits) or a valid email address'); return false; } if (!qty || isNaN(qty)) { alert('Please enter a valid quantity'); return false; } if (!contentText) { alert('Please enter content'); return false; } const formData = new FormData(this); $.ajax({ url: $(this).attr('action'), type: $(this).attr('method'), data: formData, processData: false, contentType: false, beforeSend: function() { $('.layui-btn').prop('disabled', true).text('Submitting...'); }, success: function(response) { alert('Form submitted successfully!'); $('#fdForm')[0].reset(); $('.preview_fdfile').text(''); $('.delete_fdimg').hide(); }, error: function(xhr, status, error) { alert('Error submitting form: ' + error); }, complete: function() { // Reset button state $('.layui-btn').prop('disabled', false).text('Submit'); } }); }); });

Reviews(0)
0.00
Image 0 Positive 0
See All Reviews
Questions & Answers(0)
Description

You also Interesting

(965)
(0)

Roymall Service

QQ好友QQ空间新浪微博微信朋友圈百度贴吧复制链接
取消