function getCursorPositionInTextField(textFieldObj) 
{
	//This is required if you were to be clicking on a button to invoke this
	//otherwise your selection is the button
	textFieldObj.focus();
	
	textrange = document.selection.createRange().duplicate();
	//You may have to make sure the selection and focus is with your object
	//because the selection is document level entity.
	//if (textrange.parentElement() != textFieldObj)
	//{
	//	alert("Sorry you are not the field");
	//}
	
	var i=0;
	while(textrange.move("character",1) == 1)
	{
		i++;
	}
	return textFieldObj.value.length() - i;
}

>> Saturday, March 18, 2006 10:32:42 AM - Comments by satya

The above code works only for ie