繁体   English   中英

使用PHP的邮件功能向邮件发送表单时如何在HTML中包含JavaScript / jQuery

[英]How to include JavaScript / jQuery inside HTML while sending a form to mail using mail function of PHP

我想通过验证将表格发送到邮件。 它正在工作,但是我的验证不起作用。

这是我的代码:

$send_email = "ajinkyasmore@gmail.com";
$subject = "Testing Mail.!";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$message = "<html><head>
        <link rel='stylesheet' type='text/css' href='welfare.mswarehousing.com/stylesheets/jquery.validate.css' />
        <link rel='stylesheet' type='text/css' href='welfare.mswarehousing.com/stylesheets/style.css' />
        <script src='welfare.mswarehousing.com/js/jquery-1.3.2.js' type='text/javascript'>
        </script>
        <script src='welfare.mswarehousing.com/js/jquery.validate.js' type='text/javascript'>
        </script>

        <script type='text/javascript'>         
            jQuery(function(){
                alert('inside js function');
                jQuery('#fname').validate({
                    expression: 'if (VAL == '') return false; else return true;',
                    message: 'field is null'
                });
              });               
        </script>
    </head>
    <form name='frame' id='main_frame' action='http://welfare.mswarehousing.com/thankyou.php' method='get' enctype='multipart/form-data'>
     <table width='250' cellspacing='0' cellpadding='0' border='0' align='left'>
     <tbody>
     <tr>
     <td>
     <table width='250' cellspacing='0' cellpadding='0' border='0' bgcolor='#c7ac77'>
     <tbody>
     <tr>
     <td width='15' height='15'>&nbsp;</td>
     <td>&nbsp;</td>
     <td width='15'>&nbsp;</td>
     </tr>
     <tr>
     <td>&nbsp;</td>
     <td>
     <table width='220' cellspacing='0' cellpadding='0' border='0' align='center'>
     <tbody>
     <tr>
     <td style='font-family: Calibri,Verdana; font-size: 25px; color: #ffffff; line-height: 26px;'><strong>Show Your Interest</strong></td>
     </tr>
     <tr>
     <td height='15'>&nbsp;</td>
     </tr>
     <tr>
     <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Name</td>
     </tr>
     <tr>
     <td bgcolor='#ededed' height='28' style='font-family: Arial,Verdana; font-size: 12px; color: #666666; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'>
     <input type='text' name='fname' size='26' id='fname' required/> 
     <input type='hidden' name='send_date' value='2015/08/08'>
     <input type='hidden' name='property_name' value='Drushtitechnet'>
     <input type='hidden' name='send_mail' value='$send_email'>
    </td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    <tr>
    <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Phone</td>
    </tr>
    <tr>
    <td height='28' style='font-family: Arial,Verdana; font-size: 12px; color: #666666; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'><input type='text' name='contact'  size='26' required/></td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    <tr>
    <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Email</td>
    </tr>
    <tr>
    <td height='28' style='font-family: Arial,Verdana; font-size: 12px; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'><input type='email' name='from'  size='26' required></td>
    </tr>
    <tr>
    <td height='15'>&nbsp;</td>
    </tr>
    <tr>
    <td valign='top'>
    <table width='220' cellspacing='0' cellpadding='0' border='0'>
    <tbody>
    <tr>
    <td height='40' style='font-family: Arial; font-size: 21px; text-align: center; background: #d24836; border: 1px solid #d24836; border-radius: 3px;'><a target='_blank' style='text-decoration: none; color: #ffffff; line-height: 40px; display: block;'><input type='submit' id='submit' value='I am Interested'></a></td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height='20'>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    <tr>
    <td height='20'>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </form></html>";

mail($send_email, $subject, $message, $headers);
?>

默认情况下,出于非常好的(安全性)原因,几乎所有电子邮件客户端都不接受Javascript。

使用表格引导您的读者访问网站。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM