function validateValue() { // Defining Regular Expression Pattern // This Pattern is validate the value like "a00000" var re5digit = /^\a\d{5}$/ if (document.form1.TextBox1.value.search(re5digit) == -1) //if match failed alert("Please enter a valid 5 digit number inside the text starts with 'a', Example: a00000") }