Add username lenght check onkeyup
This commit is contained in:
parent
58476a8273
commit
8cef2247c0
|
@ -70,6 +70,8 @@
|
|||
<div class="form-group">
|
||||
<input id="organization" name="organization" type="text" placeholder="Affiliation / Organization:" class="form-control"></div>
|
||||
<div class="form-group">
|
||||
<span class="msg_username_min_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Minimum username length 5 characters.</span>
|
||||
<span class="msg_username_max_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Maximum username lenght 150 characters.</span>
|
||||
<span class="msg_username_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your username.</span>
|
||||
<input id="username" name="username" type="text" placeholder="Username (*)" class="form-control"></div>
|
||||
<div class="form-group">
|
||||
|
@ -102,55 +104,71 @@
|
|||
<!-- END OF REGISTER FORM -->
|
||||
<script>
|
||||
|
||||
var myInput = document.getElementById("password");
|
||||
//var myInput = document.getElementById("password");
|
||||
var usernameInput = document.getElementById("username");
|
||||
//var myEmailInput = document.getElementById("email");
|
||||
|
||||
// When the user starts to type something inside the password field
|
||||
myInput.onkeyup = function() {
|
||||
// // When the user starts to type something inside the password field
|
||||
// myInput.onkeyup = function() {
|
||||
//
|
||||
// // Validate lowercase letters
|
||||
// var lowerCaseLetters = /[a-z]/g;
|
||||
// if (myInput.value.match(lowerCaseLetters)) {
|
||||
// $(".msg_lowercase_letter").fadeOut();
|
||||
// } else {
|
||||
// $(".msg_lowercase_letter").fadeIn();
|
||||
// }
|
||||
//
|
||||
// // Validate capital letters
|
||||
// var upperCaseLetters = /[A-Z]/g;
|
||||
// if (myInput.value.match(upperCaseLetters)) {
|
||||
// $(".msg_capital_letter").fadeOut();
|
||||
// } else {
|
||||
// $(".msg_capital_letter").fadeIn();
|
||||
// }
|
||||
//
|
||||
// // Validate numbers
|
||||
// var numbers = /[0-9]/g;
|
||||
// if (myInput.value.match(numbers)) {
|
||||
// $(".msg_number").fadeOut();
|
||||
// } else {
|
||||
// $(".msg_number").fadeIn();
|
||||
// }
|
||||
//
|
||||
// // Validate length
|
||||
// if (myInput.value.length >= 6) {
|
||||
// $(".msg_lenght").fadeOut();
|
||||
// } else {
|
||||
// $(".msg_lenght").fadeIn();
|
||||
// }
|
||||
//
|
||||
// if(myInput.value.match(lowerCaseLetters) && myInput.value.match(upperCaseLetters)
|
||||
// && myInput.value.match(numbers) && (myInput.value.length >= 6)){
|
||||
// if($(".msg_please_add").css('display')!='none'){
|
||||
// $(".msg_please_add").fadeOut();
|
||||
// }
|
||||
// } else {
|
||||
// if($(".msg_please_add").css('display')=='none') {
|
||||
// $(".msg_please_add").fadeIn();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Validate lowercase letters
|
||||
var lowerCaseLetters = /[a-z]/g;
|
||||
if (myInput.value.match(lowerCaseLetters)) {
|
||||
$(".msg_lowercase_letter").fadeOut();
|
||||
usernameInput.onkeyup = function() {
|
||||
|
||||
// Validate username minimum length
|
||||
if (usernameInput.value.length >= 5) {
|
||||
$(".msg_username_min_lenght").fadeOut();
|
||||
} else {
|
||||
$(".msg_lowercase_letter").fadeIn();
|
||||
$(".msg_username_min_lenght").fadeIn();
|
||||
}
|
||||
|
||||
// Validate capital letters
|
||||
var upperCaseLetters = /[A-Z]/g;
|
||||
if (myInput.value.match(upperCaseLetters)) {
|
||||
$(".msg_capital_letter").fadeOut();
|
||||
// Validate username maximum length
|
||||
if (usernameInput.value.length < 150) {
|
||||
$(".msg_username_max_lenght").fadeOut();
|
||||
} else {
|
||||
$(".msg_capital_letter").fadeIn();
|
||||
}
|
||||
|
||||
// Validate numbers
|
||||
var numbers = /[0-9]/g;
|
||||
if (myInput.value.match(numbers)) {
|
||||
$(".msg_number").fadeOut();
|
||||
} else {
|
||||
$(".msg_number").fadeIn();
|
||||
}
|
||||
|
||||
// Validate length
|
||||
if (myInput.value.length >= 6) {
|
||||
$(".msg_lenght").fadeOut();
|
||||
} else {
|
||||
$(".msg_lenght").fadeIn();
|
||||
}
|
||||
|
||||
if(myInput.value.match(lowerCaseLetters) && myInput.value.match(upperCaseLetters)
|
||||
&& myInput.value.match(numbers) && (myInput.value.length >= 6)){
|
||||
if($(".msg_please_add").css('display')!='none'){
|
||||
$(".msg_please_add").fadeOut();
|
||||
}
|
||||
} else {
|
||||
if($(".msg_please_add").css('display')=='none') {
|
||||
$(".msg_please_add").fadeIn();
|
||||
}
|
||||
$(".msg_username_max_lenght").fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
// myEmailInput.onfocusOut = function() {
|
||||
//
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue