Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check if username already exists in database using javascript

function validacija() {

  let user = document.getElementById('user');
  let listOptions = document.querySelectorAll("#list option");


  if (user.value.length <= 20 && user.value.length >= 3) {} else {
    alert("Username has to be between 3-20 characters.")
  }


  for (let i = 0; i < listOptions.length; i++) {
    if (listOptions[i].value === user.value) {
      alert('The name already exist')
    }
  }
  return false;
}
Comment

how to check if username already exists in database using javascript

<form onsubmit="return validacija()">
  <table>
    <tr>
      <td>Username:</td>
      <td><input type="text" id="user" name="user" list="list"></td>
      <datalist id="list">
                    <option value="Tilen">
                    <option value="Marko">
                    <option value="Teja">
                    <option value="Tisa">
                    <option value="Rok">
                    <option value="Luka">
                    <option value="Mojca">
                </datalist>
    </tr>
  </table>
</form>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react fun tion 
Javascript :: array empty strings 
Javascript :: remove duplicated from array 
Javascript :: create a javascript json object 
Javascript :: react firebase add doc to collection 
Javascript :: angular router navigate inside setTimeout 
Javascript :: first unique character in a string javascript 
Javascript :: nodejs remove element from array 
Javascript :: how to include a toasted property in vue 
Javascript :: javascript .target 
Javascript :: Font Size changed from device OS react native app 
Javascript :: meteor create package 
Javascript :: javascript append list to list 
Javascript :: How to append the string to the current url in jquery | Javascript 
Javascript :: /learn ES6: Use the Spread Operator to Evaluate Arrays In-Place 
Javascript :: good way to check object properties in js 
Javascript :: how to get 3rd li using jquery 
Javascript :: setinterval 
Javascript :: usestate previous state 
Javascript :: convert string with dot or comma as decimal separator to number in javascript 
Javascript :: bootstrap 4 open tab when opening modal 
Javascript :: interactive svg javascript 
Javascript :: js get html title 
Javascript :: react fetch data in for loop 
Javascript :: _.extend 
Javascript :: async await react stackoverflow 
Javascript :: Selectores de jQuery CSS básicos 
Javascript :: javascript rest 
Javascript :: passing props in react functional components 
Javascript :: filter buttons react 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =