yourbudweiser
asked on
Limit Textbox Entry
I want to limit the text entered into my textbox in the following ways:
If name="Jed" Then
maxLength="6"
ElseIf name="Ted" Then
maxLength="5"
Else maxLeength="4"
Also, you can only enter the following characters:
FLAfla1234567890
Also, you can only enter the following combo of letters:
either FL
or A
You may only enter one A or you may enter FL or you can enter no letters but numbers only!
If name="Jed" Then
maxLength="6"
ElseIf name="Ted" Then
maxLength="5"
Else maxLeength="4"
Also, you can only enter the following characters:
FLAfla1234567890
Also, you can only enter the following combo of letters:
either FL
or A
You may only enter one A or you may enter FL or you can enter no letters but numbers only!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script type='text/javascript'>
<!--
function validate(obj) {
val=obj.value
re1=/(F)/i
re2=/(L)/i
re3=/(A)/i
re4=/(\d+)/
re5=/[^FLA0-9]/i
q=0
if(re1.test(val)) q=q+.5
if(re2.test(val)) q=q+.5
if(re3.test(val)) q++
if(re4.test(val)) q++
if(re5.test(val)) q=q+2
if(q==1) {
alert("OK")
return true;
} else {
alert("NOT OK")
return false;
}
}
//-->
</script>
<form onSubmit='validate(this.fo
<input type='text' name='joe'><br />
<input type='submit value='CLICK'>
</form>