Click to See Complete Forum and Search --> : validate lowercase char only


javascriptuser1
11-19-2003, 05:02 AM
hi all,
i want to validate username text field should accept lowercase characters.


how to do this.

Charles
11-19-2003, 05:13 AM
<input type="text" onchange="this.value = this.value.toLowerCase()">

or

<input type="text" onchange="if (this.value != this.value.toLowerCase()) {alert('That would not appear to be a valid user name.'); this.value = ''; this.focus()}">

or

<input type="text" onchange="if (!/^[a-z]+$/.test(this.value)) {alert('That would not appear to be a valid user name.'); this.value = ''; this.focus()}">

javascriptuser1
11-19-2003, 05:18 AM
thanks its works great.