任何onkeyup或onclick javascript代码,可帮助我在9个字符后提交表单。
我的HTML代码。我正在使用AJAX来获取数据。我尝试了很多脚本。没有人适合我:'(
Enter Your Car No : <input type="text" name="car" maxlength="9" id="carno" value="<?php echo $_REQUEST["carno"]; ?>"/>
答案 0 :(得分:0)
Enter Your Car No : <input type="text" name="car" maxlength="9" id="carno" onkeypress="yourFunction()" value="<?php echo $_REQUEST["carno"]; ?>"/>
<script>
function yourFunction(){
var textValue = document.getElementById('carno').value;
if(textValue.length >= 9){
//implement your ajax code
}
}
</script>
Hai here i am calling function on each key press in that text field and i am getting the value using id and checking that length if its >=9 (ur requirement) so write ajax code
答案 1 :(得分:0)
试试这个:
Enter Your Car No : <input type="text" name="car" maxlength="9" id="carno" value="<?php echo $_REQUEST["carno"]; ?>" onkeypress="submitForm()" onclick="submitForm()"/>
<script>
function submitForm(){
var len = document.getElementById("carno").value.length;
if(len >= 9 ){
//submit form code
}else{
return false;
}
}
</script>