Jump to content

Focus function of javascript in Mozila


pr.nimbalkar

Recommended Posts

Hi friends, function changeVal(obj,val){ var i = val.indexOf("."); var l = val.substring(i,val.length); if(l.length > 2) { alert("There should be only one numeric value after the decimal point"); setTimeout('obj.focus();',1); return false; } }This script gives an error 'obj' not defined.How to fix this bug?

Link to comment
Share on other sites

I have a hard time getting setTimeout to work sometimes too. Try this.

function changeVal(obj,val){  var i = val.indexOf(".");  var l = val.substring(i,val.length);  if(l.length > 2)  {	alert("There should be only one numeric value after the decimal point");	setTimeout(setFocus,1);	return false;  }  function setFocus()  {	obj.focus();  }}

try that

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...