SHTML和JavaScript不起作用

时间:2017-10-11 03:04:27

标签: javascript include-path shtml

我遇到的问题是我的javascript无法在我的包含文件中运行,这是一个SHTML文件。这是针对我正在研究的课程,但是由于我们没有SSI,所以我们必须使用SHTML,所以我们可以使用#includes这就是我所拥有的。我只是喜欢这本书但是没有用。现在这是我的头文件

include virtual="../common/document_head.shtml"-->
<body>
    <header>
        <!--#include virtual="../common/logo_row.shtml"--> 
        <!--#include virtual="../common/mainmenu_row.shtml"-->
    </header>
    <h3>Customer Feedback Form</h3>
    <form id="contactForm" onsubmit="feedbackFormValidate()">
        <table>
                <tr>
                <td>Salutation:</td>
                <td><select name="salute">
                <option>&nbsp;</option>
                <option>Mrs.</option>
                <option>Ms.</option>
                <option>Mr.</option>
                <option>Dr.</option>
                </select></td>
                </tr>
                <tr>
                <td>First Name:</td>
                <td><input type="text" name="firstName" size="40"></td>
                </tr>
                <tr>
                <td>Last Name:</td>
                <td><input type="text" name="lastName" size="40"></td>
                </tr>
                <tr>
                <td>E-mail Address:</td>
                <td><input name="email" size="40" type="text"></td>
                </tr>
                <tr>
                <td>Phone Number:</td>
                <td><input type="text" name="phone" size="40"></td>
                </tr>
                <tr>
                <td>Subject:</td>
                <td><input type="text" name="subject" size="40"></td>
                </tr>
                <tr>
                <td>Comments:</td>
                <td><textarea cols="30" name="message" rows="6"></textarea></td>
                </tr>
                <tr>
                <td colspan="2">Please check here if you wish to receive a reply: 
                <input type="checkbox"  name="reply" value="yes"></td>
                </tr>
                <tr>
                <td><input type="submit" value="Send Feedback"></td>
                <td class="RightAligned">
                <input type="reset" value="Reset Form"></td>
                </tr>
        </table>
    </form>
    <footer>
        <!--#include virtual="../common/footer_row.shtml"-->
    </footer>
</body>

现在这是我的feedback.shtml文件。一切都在javascript旁边

function feedbackFormValidate()
{
var contactFormObj = document.getElementById("contactForm");
var firstName = contactFormObj.firstName.value;
var lastName = contactFormObj.lastName.value;
var phone = contactFormObj.phone.value;
var email = contactFormObj.email.value;
var everythingOK = true;

if (!validateName(firstName))
{
    alert("Error: Invalid first name.");
    everythingOK = false;
}

if (!validateName(lastName))
{
    alert("Error: Invalid last name.");
    everythingOK = false;
}

if (!validatePhone(phone))
{
    alert("Error: Invalid phone number.");
    everythingOK = false;
}

if (!validateEmail(email))
{
    alert("Error: Invalid e-mail address.");
    everythingOK = false;
}

if (everythingOK)
{
    if (contactFormObj.reply.checked)
        alert("Warning: The e-mail feature is currently not supported.");
    alert("All the information looks good.\nThank you!");
    return true;
}
else
    return false;
}

function validateName(name)
{
var p = name.search(/^[-'\w\s]+$/);
if (p == 0)
    return true;
else
    return false;
}

function validatePhone(phone)
{
var p1 = phone.search(/^\d{3}[-\s]{0,1}\d{3}[-\s]{0,1}\d{4}$/);
var p2 = phone.search(/^\d{3}[-\s]{0,1}\d{4}$/);
if (p1 == 0 || p2 == 0)
    return true;
else
    return false;
}

function validateEmail(address)
{
var p = address.search(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})$/);
if (p == 0)
    return true;
else
    return false;
}

这是我的。 js文件

UDID

任何帮助或想法都会很棒!感谢

1 个答案:

答案 0 :(得分:0)

弄明白Ipages一直在提交。