<html>
<head>
<script language= "JavaScript">
function ckdec() {
var refstring = /^0/; //sets ref for char to be searched for
var mystrg = document.form1.testval.value;
if (mystrg.search(refstring) > -1) { // if search returns found value > -1
alert ("text sarts with a 0!" }
else { alert ("text doesn't start with a 0!"}
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="testval" size="15" value="enter a num">
<input type="button" value="click to test" onClick="ckdec();">
</form>
</body
</html>
Looks to me like your last: "^[1-9][0-9"
Since you left "0" out of the range by using "[1-9]"
should work O.K.>>>but by my tests using variables
such as "+lmin","+lmax+" will have to be replaced with
literals such as {2,9}
Another thing to consider is that your leaving an opening
with your first [1-9] statement--there is no limit to the
amount of times digits can occur....
You might consider /^[1-9]{1}[0-9]{1,6}$/ this statement
limits your first occurence range to 1 then your second
occurence range is "1 not more than 6" for a total of
7 digits.
What I meant to say earlier was that using those variables
inside the "{" "}" didn't work for me at all.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.