Ike wrote on 06 mrt 2004 in comp.lang.javascript
:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29... Ike wrote on 06 mrt 2004 in comp.lang.javascript:
> Does anyone know where I can find example scritp for formatting
> text input? I want to have a text box where only legitiamte
> filesname under unix can be netered > (no whitespace, only alphanumeric, must start alpha)
testresult = /^[a-z][a-z0-9]*$/i.test(filename)
what about a period [.] ?
I dont understand though....how do you incorporate that into a text
element on a form? Thank You -Ike
[please do not toppost on usenet]
That depends on what you want to achieve.
I hope you try to experiment awith and learn something from this.
<script>
function test(x){
unix = x.unix.value
if(/^[a-z][a-z0-9]*$/i.test(unix)){
// (no whitespace, only alphanumeric, must start alpha)
return true // submit allowed
}
alert("Not an allowed string") // warning
return false // submit prevented
}
</script>
<form onsubmit="return test(this)">
<input name=unix>
<input type=submit>
</form>
IE6 tested
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)