JavaScript and client side scripting.
Moderator: General Moderators
nincha
Forum Contributor
Posts: 191 Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA
Post
by nincha » Sun Apr 20, 2003 12:05 pm
okay, a number validation is <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> me off...im very bad at JS and cant find a way to distinguish a string from a number....If any one can help, it be very nice of yah...thnx
AND can any one find the error in this code, thnx
Code: Select all
onClick="
var Fcount = 0
var Formstatus = true
while ((Fcount < document.formsїblah].elements.length) && (Formstatus))
{
if (document.formsїblah].elementsїFcount].value == '''')
{
alert(''Please complete all fields.'')
document.formsїblah].elementsїFcount].focus()
Formstatus = false
}
Fcount ++
}
return Formstatus
">
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Apr 20, 2003 8:50 pm
why backslashes?
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>validating numbers with js-regex</title>
<script type="text/javascript">
<!--
function myTest()
{
var ex = /^\d+$/;
var oi = document.getElementById("i1");
if (ex.test(oi.value) == false)
oi.style.color = "red";
else
oi.style.color = "";
}
-->
</script>
</head>
<body>
<p>
<label for="i1">digits only</label>
<input type="text" id="i1" onKeyup="javascript:myTest();" />
</p>
</body>
</html>
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Mon Apr 21, 2003 6:24 am
What error message do you get?