Adi*_*ian 0 javascript php forms submit
我的代码有问题..我想在填写长度为10位数的文本框后自动提交.
这是我的javascript代码
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$("#idnya").on("input propertychange", function()
{
if($(this).val().length ==15){
$("#max").submit()
}
});
</script>
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的PHP代码
<?php
include "koneksi.php";
echo"
<body>
<form id=max name='cingcing' action='lanjut.php' method='POST'>
<center>
<table>
<tr>
<td colspan=2> <center> id </center> </td>
</tr>
<tr>
<td> id number </td> <td> <input type=password id='idnya' name='idnya2'> </td>
</tr>
</center>
</form>
</body>
";
?>
Run Code Online (Sandbox Code Playgroud)
小智 6
在文档"准备就绪"之前,无法安全地操作页面.我想你忘记了这个ready功能.要检查长度,您可以绑定keyup事件,如下所示.
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
$("#idnya").on("keyup",function(){
if($(this).val().length == 10){
$("#max").submit();
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)