In article <us***************@newssvr13.news.prodigy.com>,
ts**********@ftsolutions.com enlightened us with...
That would be fine, but the user may be entering 12 dates and I don't want
him to find out that all the dates are in the wrong format after he has
entered them all. I want to allow him to see it right when it happens.
Otherwise, I would just let ASP.Net handle the validation.
A few ideas here.
ASP.NET has a control for choosing dates. Instead of relying on the user to
enter a date in a certain format, you may want to use the date chooser
control instead.
http://www.macromedia.com/devnet/mx/...pnet_calendar_
03.html
I don't get to use .NET for my application that involves a lot of dates, so I
specify to the users what the format is right next to the date control. If
they can't read, they learn the hard way. ;)
All that said, the focus/blur thing is a common and well-known issue. There
are various workarounds. Here's a simple one I made that has been tested in
Firefox and MSIE. It needs fleshed out and you may want to allow another
control to be focused even if the current one is invalid.
What it currently does is checks the validity of a control and won't allow
focus off until it is valid.
Play with it and see if you like it. Change what you need until you get the
desired behavior.
And don't forget to put in comments and error checking and the like. This is
just a little something I was playing with, so it is nowhere near production
quality code. Have fun.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var err = false;
var currentControl = null;
function controlFocused(control)
{
if (err == false)
{
currentControl = control;
}
if (currentControl != null) currentControl.focus();
}
function checkIt(e)
{
if (e.length==0 || e.length==10)
{
err = false;
return true;
}
else
{
alert("Please enter a valid value for " + e.name + ".");
err = true;
return false;
}
}
</script>
</head>
<body>
<form name="form1" method="get" action="">
<p>Date 1
<input name="date1" type="text" id="date1" onFocus="controlFocused
(this);" onChange="checkIt(this)">
</p>
<p>Date 2
<input name="date2" type="text" id="date2" onFocus="controlFocused
(this);" onChange="checkIt(this)">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
--
--
~kaeli~
If a turtle doesn't have a shell, is he homeless or naked?
http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace