i've created a form with several fields, input, select, box etc. i've 2 fields that must be validated agaist DB. If exists show some details if not display some aditional input fields to add to DB.
Ex: Make, model, licenseplate. IF licenseplate exists -> Honda Accord IF NOT -> input to add .
$(document).ready(function(){
$("licplate").change(function(){
var lp = $("licplate").val();
if(lp.length <= 8) { //my country have a 8 digit plate
$("#stat").html('<image> Verifing');
$.ajax({
type: "POST",
url: "check.php",
data: "licplate="+lp,
success: function(msg) {
$("#stat"),ajaxComplete(function(event,request,settings){
if(msg=='OK'){
$(this).html('message to ignore');
} else {
$(this).html(msg);
}
In my check.php i connect to db, validate and return data. If exist return
echo "<span class="msg">$row_sql_chk['make']." - ".$row_sql_chk['model']</span>";
if not
<li><label>Make</label><input id="make" name="make" type="text" />
<li><label>Modele</label><input id="model" name="model" type="text" />
It work just fine, however i've got a new validation to make in another input field on form. I must validate the driver the same way.. is exits the "driverlicense" show name and address if not include fields to insert it. I did the same code, change fieldnames, the div name etc.. And work just fine.
But then came the problem... if both of the fields dont exist. I fill the fields (make, model) and when validating the driver, if not exist it clears the top fields. After that if i fill (again) all the fields (make, model, name..) works just as expected. So how can i do the 2nd field validation without cleaning the other? tks