I am trying to allow the login input to be either username & password or email & password. How do I use the javascript function to tell whether the input is a username or an email? I am using vanilla js so no jquery or PHP, thanks!
vanilla js
I am trying to allow the login input to be either username & password or email & password. How do I use the javascript function to tell whether the input is a username or an email? I am using vanilla js so no jquery or PHP, thanks!
vanilla js
Call this function on submit
function validate() {
var login = document.getElementById('field').value;
// Check if email
if (/\@/.test(login)) {
//its email address
// your code goes here
}
else {
//its username
// your code goes here
}
}