I want to every word start with capital letter and rest of are should be in small letters while entering in text field.
I don't know how to give regular expression.
I want to every word start with capital letter and rest of are should be in small letters while entering in text field.
I don't know how to give regular expression.
Looks like a classic capitalization function.
input.value = input.value.replace(/\b[a-zA-Z]+/g,
function(m) {return m.charAt(0).toUpperCase()+m.substring(1).toLowerCase();})
Assuming you want to validate some input, you should write a match for what you don't want and then negate it:
!( /\b[a-z]|\w[A-Z]/.test(input_string) )
This regex matches for lowercase letters at the start of a word or uppercase letters immediately after another letter (i.e., in the middle of a word). If you negate this result, as I have done here, you'll get the validation you want.
MDN has a good intro to Regular Expressions and the JavaScript RegExp object