use*_*394 15 javascript validation input
输入检查有问题.如果输入长度小于3,我不想发送请求.
我的表格:
<form method='post' action=''>
Alb?ma nosaukums: # # this is the input --><input id='titleeee' type='text' name'album_title' /><br />
Bilde Nr 1: <input type='file' name='pic_nr1' /><br />
Bilde Nr 2: <input type='file' name='pic_nr2' /><br />
Bilde Nr 3: <input type='file' name='pic_nr2' /><br />
Akt?vs*:
<select>
<option>J?</option>
<option>N?</option>
</select>
<br />
<input Onclick='testlenght(document.getElementById("titleeee"), "Tavs alb?ma nosaukums ir pa ?su!", "3")' type='submit' value='Pievienot' />
</form>
Run Code Online (Sandbox Code Playgroud)
dm0*_*514 29
您可以在onsubmit处理程序中添加表单,例如:
<form onsubmit="return validate();">
</form>
<script>function validate() {
// check if input is bigger than 3
var value = document.getElementById('titleeee').value;
if (value.length < 3) {
return false; // keep form from submitting
}
// else form is good let it submit, of course you will
// probably want to alert the user WHAT went wrong.
return true;
}</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
130000 次 |
| 最近记录: |