i need a regular expression in javascript validation. Regular expression for name field that will accept alphabets and only space character between words and total characters in the field should be in between 2 and 30. i.e., the field should accept min 2 chars and max of 30 chars
function validate(id) {
    var regex = /^[a-zA-Z ]{2,30}$/;
    var ctrl =  document.getElemetnById(id);
    return regex.test(ctrl.value);
}
                        Try this:
/^([a-zA-Z ]){2,30}$/
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With