We have an application that displays an error message if an entry in a field is invalid and does not allow the user to exit the field. It has a bunch of code to test a regular expression, followed by: var myReg = new RegExp(Expr) if (!myReg.test(Str) && Str != '' && Expr != ' ') { alert(Msg); if (WarningMsg == -1){ window.event.cancelBubble = true; event.returnValue=false; } In IE6, this prevents the user from leaving the field until a valid value is entered, but this does not work in IE7. I'm told that this is by design, but I need either a workaround or a Microsoft web page to document why it won't. Can anyone help?
"brilliantatbreakfast" wrote in message news:6e87fa1d-c1d7-49a8-9ee4-8d0140c08761@x41g2000hsb.googlegroups.com... > We have an application that displays an error message if an entry in a > field is invalid and does not allow the user to exit the field. It > has a bunch of code to test a regular expression, followed by: > > var myReg = new RegExp(Expr) > if (!myReg.test(Str) && Str != '' && Expr != ' ') > { > alert(Msg); > if (WarningMsg == -1){ > window.event.cancelBubble = true; > event.returnValue=false; > } > > In IE6, this prevents the user from leaving the field until a valid > value is entered, but this does not work in IE7. I'm told that this > is by design, but I need either a workaround or a Microsoft web page > to document why it won't. > > Can anyone help? Popping up message boxes and/or preventing navigation around the form is a fairly hostile way to treat the user anyway. I would suggest that you design out this requirement. Place an indicator next to the invalid field which carries a title that'll appear as tool tip then the user hovers the mouse pointer over it. Leave the submit button disabled until the set of fields are valid. -- Anthony Jones - MVP ASP/ASP.NET