Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jQuery Validate remote method usage to check if username already exists

//HTML
$("#signupForm").validate({
  rules: {
    username: {
      required: true,
      minlength: 3,
      remote: "check-username.php"
    }
  },
  messages: {
    username:{
      remote: "This username is already taken! Try another."
    }
  }
});

//PHP code of check-username.php
<?php

header('Content-type: application/json');
$request = $_REQUEST['username'];

$query = mysql_query("SELECT * FROM mmh_user_info WHERE username ='$username'");
$result = mysql_num_rows($query);
if ($result == 0){
$valid = 'true';}
else{
$valid = 'false';
}
echo $valid;
exit;
?>
Comment

PREVIOUS NEXT
Code Example
Javascript :: await reserved word testcafe using await in loop 
Javascript :: show image in popup from owl carousel pop up 
Javascript :: vuetify checkbox click firing twice 
Javascript :: super slider js 
Javascript :: Code is valid JSON equivalent of the key/value pair shown that also preserves the original value: UPC: 043875 
Javascript :: how to exclude required files from grunt merge 
Javascript :: discord.js how to go back a file 
Javascript :: destruct e.target.value param 
Javascript :: how to write a program that determines the minutes since midnight, Jan 1, 1970 in javascript 
Javascript :: redblobgames pathfinding 
Javascript :: if(gender.length === 0) javascript 
Javascript :: conditional rendering alert if input fields are empty 
Javascript :: jquery dialog button text set by variable 
Javascript :: change dxform label angular 
Javascript :: how to set state for logged in users 
Javascript :: angular specific attributes and locators list 
Javascript :: how to use getBackgroundPage 
Javascript :: hide url in discord.js 
Javascript :: ladder physics javascript 
Javascript :: choropleth map of india which shows current date confirmed cases in every state json api python. 
Javascript :: how to test timeout in component did mount 
Javascript :: show object unordered in chrome console 
Javascript :: application/ld+json react 
Javascript :: sbi debit card customer care number 
Javascript :: js var 
Javascript :: react how to block render if data is not fetched yet 
Javascript :: how to use yes no statement with alert in tampermonkey 
Javascript :: ipa failed react native after processing 
Javascript :: jszip file bufer 
Javascript :: generate random hsl color values 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =