php - set javascript validation based on condition -


i m trying check whether username exits in db or not. if exits should give error msg , prevent user add details db till edit user field or make valid or available. ajax call

$('#user').keyup(function(e) {     var check_user=$(this).val();     $.ajax({         type: "post",          url: "ajax.php",         data: {check_user:check_user},         success: function(data)         {                $("#user-result").html(data);          }     });          }); 

ajax.php

if(isset($_post['check_user'])){     $class->mqry="and barcode='".$_post['check_user']."' "; $class->selected_fields=array('this.user_id'); $check_user= $class->gettable('users');  $class->resetfields(); $count=count($check_user); if($count) {     die('<img src="imgs/not-available.png" />user exits'); }else{     die('<img src="imgs/available.png" />'); }  } 

this things working.now how can prevent user add details.i wan set validation user field.i hope make sence.

here take user example. in real there details barcode etc...

you need use client side validation before send ajax - if validation on client side passes, send ajax , register callbacks. also, perform validation on server side , not rely on client side validation only. parsleyjs 1 option - can use jquery validation or roll own own (probably best use third party validation library).


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -