- Posts: 2
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> function checkID(str) { if (str.length == 0) { document.getElementById("check").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("check").innerHTML = xmlhttp.responseText; document.getElementById("check1").value = xmlhttp.responseText; } } xmlhttp.open("GET", "id.php?q=" + str, true); xmlhttp.send(); } } </script> <p><b>Start typing a name in the input field below:</b></p> First name: <input type="text" onkeyup="checkID(this.value)"> <p>Check: <span id="check"></span></p> <br> <input type="hidden" id="check1" value=""/>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function() { $("#1").keyup(function() { var txt = $("#1").val(); $.post("id.php", {id: txt}, function(result) { $("#2").html(result); $("#3").val(result); }); }); $("form#11").submit(function() { if ($("#3 input.text").val() == "" || $("#3 input.text").val() == 0) { alert("false"); return false; } else { return true; } }); }); }); </script> </head> <body> <form id="11"> <input type="text" id="1"> <p>c: <span id="2"></span></p> <input type="text" id="3" value=""/> <button type="submit" id="movenextbtn" value="movenext" name="movenext" accesskey="n" class="submit button">Weiter</button> </body> </html>
<?php // ID $a[] = "1111"; $a[] = "2222"; $a[] = "3333"; $q = $_REQUEST["id"]; $match = 0; foreach($a as $name) { if ($q !== "") { if ($q === $name) { $match = 1; break; } else { $match = 0; } } } if ($match == 0){ echo "0"; }else{ echo "1"; } ?>
$("form#11").submit(function() { if ($("#3 input.text").val() == "" || $("#3 input.text").val() == 0) { alert("false"); return false; } else { return true; } }); });
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function() { var x = 0; $("#check_01").val(x); $("#question5").keyup(function() { var txt = $("#question5").val(); $.post("id.php", {id: txt}, function(result) { $("#check_01").val(result); }); }); $("form#limesurvey").submit(function() { if( $("#check_01").val() == 0 || $("#check_01").val() == "" ) { alert("void"); return false; } else { alert("true"); return true; } }); }); </script> </head> <body> <form id="limesurvey" action="test2.html" method="post"> <input type="text" id="check_01" value=""/> <input type="text" id="question5" value=""/> <button type="submit" id="movenextbtn" >Weiter</button> </form> </body> </html>
<input type="hidden" id="check_01" value=""/> <script> $(document).ready(function() { var x = 0; $("#check_01").val(x); $("#question5").keyup(function() { var txt = $("#question5").val(); $.post("id.php", { id: txt }, function(result) { $("#check_01").val(result); }); }); $("form#limesurvey").submit(function() { if( $("#check_01").val() == 0 || $("#check_01").val() == "" ) { alert("void"); return false; } else { alert("true"); return true; } }); }); </script>