View Full Version : check if AT LEAST ONE character in a textbox is a letter

10-20-2005, 09:50 AM
I am looking for a function to attach onto the onKeyUp event of this textbox that will check if AT LEAST ONE character in a textbox is a letter?

seat_zelle.innerHTML = "<input type='text' id='specify"+s+"' name='specify"+s+"' "+
"title='Insert Seat Number for Pax: "+ passagier + " " + passNo + " / Segment "+ parseFloat(s+1) +"' "+
"class='selects' size='5' onBlur='concatSeats(this.value,"+passNo+",this.id,"+pass+");' onKeyUp='this.value=this.value.toUpperCase(); return IsNumeric(this.value,this.id);' />";



10-20-2005, 02:29 PM
Use a regular expression.

regex I'd use:

(beginning of line/string followed by 0 or more characters followed by one or more letters followed by 0 or more other characters followed by end of line/string)

I'm not a regex guru, so there may be a better one.

10-20-2005, 04:19 PM
Yeap regexp is the clue. But... I have a quest:

to attach onto the onKeyUp event

It is a rather unuseful event for your problem... To check if at least one of the characters is something, I guess that onchange or onblur will be proper. If the user has not ended his text, what is the use to capture the string onkeyup? Wouldn't be better to validadte the text at the end, but not while typing?

What is your final aim? validadte against letters or special characters?