Velocity Reviews

Velocity Reviews (
-   Javascript (
-   -   bring focus to text field on submit (

Dwayne Epps 07-16-2003 06:43 AM

bring focus to text field on submit
I'm using a RegExp Validator extension on a text field and was curious if
anyone know how to edit the following code to bring focus and select the
string within the text field when invalid characters are entered, so the
user can correct the invalid entry? Currently, the extension will validate
the first text field and continue on to the next text field after the user
clicks on the error message. If possible, I would like the text field to be
brought back to focus and select the invalid string within the text field
after the user clicks on the error message before it begins validating the
next text field. Any ideas? Thanks in advance.

function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
if(!x && document.getElementById) x=document.getElementById(n); return x;

function tmt_regExpValidator(f,re,eMsg,ru,r){
var myErr="";var fv=MM_findObj(f).value;var rex=new RegExp(unescape(re));
t=eval(ru+rex.test(fv));if(r){if(fv.length<=0||!t) {alert(unescape(eMsg));myE
if(fv.length>0&&!t){alert(unescape(eMsg));myErr+=" eMsg";}document.MM_returnV

All times are GMT. The time now is 08:05 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.