...

View Full Version : Resolved check that first position is not numeric



durangod
11-28-2012, 03:55 PM
Im trying to validate a name input. I do not want the first char

charAt(0) to be numberic 0123456789

dont care if the rest of the name has numbers i just have to make sure the very first char is not numeric.

any ideas

i wonder if i can do

value.indexOf.charAt(0)
something like that

WolfShade
11-28-2012, 03:58 PM
Just check indexOf for integer. If the indexOf == 0, first character is an integer. If it's -1 or >1, all good.

Philip M
11-28-2012, 04:01 PM
<script type = "text/javascript">
var n = "2abcde";
if (/^\d/.test(n)) {
alert ("Name must not begin with a digit")
}
</script>


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

durangod
11-28-2012, 04:16 PM
Excellent thank you both, Philip exactly what i needed thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum