How would I use JavaScript to check the contents of a text
box/text area
when it loses the focus?
Thanks,
ATO
JavaScript Gurus
after the other %26lt;no_such_address@offtheball.coz.zzz%26gt;
wrote:
%26gt; How would I use JavaScript to check the contents of a
text box/text
%26gt; area when it loses the focus?
onblur=''yourCheckAlgo();''
--
Kind regards,
magoo
JavaScript Gurus
%26gt;%26gt; How would I use JavaScript to check the contents of
a text box/text
%26gt;%26gt; area when it loses the focus?
%26gt;
%26gt; onblur=''yourCheckAlgo();''
Hi Magoo,
And what would I put into the yourCheckAlgo routine?
For instance, let's say that I want to check to see whether a
certain
person's name is in the field, but that there may be more
data in the field
than just the name (e.g. 'Magoo is from Europe')
Thanks,
ATO
after the other wrote:
%26gt;%26gt;%26gt;How would I use JavaScript to check the contents
of a text box/text
%26gt;%26gt;%26gt;area when it loses the focus?
%26gt;%26gt;
%26gt;%26gt;onblur=''yourCheckAlgo();''
%26gt;
%26gt;
%26gt; Hi Magoo,
%26gt;
%26gt; And what would I put into the yourCheckAlgo routine?
%26gt;
%26gt; For instance, let's say that I want to check to see
whether a certain
%26gt; person's name is in the field, but that there may be
more data in the field
%26gt; than just the name (e.g. 'Magoo is from Europe')
%26gt;
%26gt; Thanks,
%26gt;
%26lt;script type=''text/javascript''%26gt;
function yourCheckAlgo(formControl,listOfAcceptableNames){
var argLen=arguments.length;
for(var i=1;i%26lt;argLen;i++){
var Reg=new RegExp(arguments
,''i'');
if(Reg.test(formControl.value)){return true;}
}
alert(''Not acceptable'');
formControl.focus();
return false;
}
%26lt;/script%26gt;
%26lt;form%26gt;
%26lt;p%26gt;%26lt;input type=''text''
onchange= ''yourCheckAlgo(this,'Tom','Dick','Harry')''
%26gt;Gents%26lt;/p%26gt;
%26lt;p%26gt;%26lt;input type=''text''
onchange= ''yourCheckAlgo(this,'Thelma','Louise')'' %26gt;
Ladies%26lt;/p%26gt;
%26lt;/form%26gt;
Mick
No comments:
Post a Comment