1
I need you to type in input, it check in the database if there is an equal record, as those user creation fields in email.
I believe it’s in the onBlur
of input, and use a if ==
in the command, the problem is: how I call SQL values for comparison?
No search button, it has to be while typing (onblur).
The input is limited to 7 characters.
<input name="placa" id="placa" type="text" value="" pattern="[A-Za-z]{3}[0-9]{4}" size="20" maxlength="7" required onkeyup="this.value = this.value.toUpperCase();" onblur="verifExists(digs)">
DIV hidden after input
<div class="style12" id="jaexistedv" style="display:none">Placa já registrada!</div>
PHP + Java
$search_buscar = "-1";
if (isset($_GET['placa'])) {
$search_buscar = (get_magic_quotes_gpc()) ? $_GET['placa'] : addslashes($_GET['placa']);
}
mysql_select_db($database_LocalPHP, $LocalPHP);
$query_buscar = sprintf("SELECT * FROM bdsul WHERE bdsul.placa LIKE '%s'", $search_buscar);
$buscar = mysql_query($query_buscar, $LocalPHP) or die(mysql_error());
$row_buscar = mysql_fetch_assoc($buscar);
$totalRows_buscar = mysql_num_rows($buscar);
<script type="application/javascript">
function verifExists(digs) {
var regpl = <?php echo $row_buscar['placa']; ?>;
if (digs == regpl) {
document.getElementById("jaexistedv").style = "display:show";
}
}
</script>
You will need an Ajax call to access the database. Which backend language you are using?
– Eduardo F G
PHP+Javascript. I’m not using include/require Once except for the connection. CSS + Javascript all included in the document itself and not in the same place, so scattered in the middle of the document, for example: when there is an event in a select, the "application/javascript" ta before.
– César Mattos