This script is working properly to validate alphanumeric without spaces. But how will i also include that the minimum length should be at least 3 chars?
var re = /^[A-Za-z0-9']+$/; // Check input if (re.test(document.getElementById(x).value)) { // Style green document.getElementById(x).style.background = '#ccffcc'; // Hide error prompt document.getElementById(x + 'Error').style.display = "none"; return true; } else { // Style red document.getElementById(x).style.background = '#e35152'; // Show error prompt document.getElementById(x + 'Error').style.display = "block"; return false; } Thanks in advance.