我需要創建一個名爲footer.js
的腳本來驗證下面的表單。我無法對index.html
文件進行任何修改。調用JavaScript沒有功能?
我需要驗證name
字段爲空格爲3個字符,而age
字段爲1至110之間的數字。需要所有字段。
我該怎麼做?我如何打電話給我的footer.js
文件?甚至沒有onsubmit
函數,只有<form action="#">
。
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/footer.js"></script>
<form action="#">
<fieldset>
<legend>Contact</legend>
<div class="textinput">
<label for="name">Name</label>
<input type="text" name="name">
</div>
<div class="textinput">
<label for="name">Age</label>
<input type="text" name="age>
</div>
<div class="radioSelection">
<label>Select one</label>
<input type="radio" name="favorit" id="html" value="html">
<label for="html">HTML</label>
<input type="radio" name="favorit" id="js" value="js">
<label for="js">JavaScript</label>
<input type="radio" name="favorit" id="css" value="css">
<label for="css">CSS</label>
</div>
<div class="textareainput">
<label for="info">About you:</label>
<textarea></textarea>
</div>
<div class="action">
<button>Send</button>
</div>
</fieldset>
</form>
查看不顯眼的jquery。您擁有js文件中的所有工具。 (「submit」,function(){...});})' – mplungjan 2015-02-08 21:58:20
您可以使用javascript修改html元素,而不是通過修改它們index.html文件直接。 – Eclecticist 2015-02-08 22:05:23