(function () {
addOptions();
var validateBtn = document.getElementById("validate");
validateBtn.addEventListener('click', isValid, false);
function isValid() {
var username = document.getElementById('username').value.trim().toLowerCase();
var doy = document.getElementById("doy").value.trim();
var gender = document.getElementById("gender").value.trim();
var location = document.getElementById("location").value.trim();
/*
* Regex to validate the username
* min: 5 chars and max: 26chars
* allowed chars: A-Za-z0-9-_.
* Required
* should be unique
* Can't be changed in Edit profile page
*/
var regex = /^[0-9a-zA-Z-_.]{5,26}$/;
// if(username.length >=5 && username.length <=26 ) {
if (regex.test(username)) {
if (doy) {
if (gender) {
if (location) {} else {
console.log("Please place the marker in map");
}
} else {
console.log("Please select gender");
}
} else {
console.log("Please select a valid year");
}
} else {
console.log("Please enter a valid Username");
}
//} else {
// console.log("Error");
//}
}
/*
* Append doy dynamcially and store
* and selected value should be shown in Edit profile page
*/
function addOptions() {
var doy = document.getElementById("doy");
var currentYear = new Date().getFullYear();
var maxYear = currentYear - 6;
var minYear = currentYear - 100;
for (var i = maxYear; i >= minYear; i--) {
var doyNode = document.createElement('option');
doyNode.text = i;
doyNode.value = i;
doy.appendChild(doyNode);
}
}
})();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.