this is the text field code:
Code: Select all
<input class='tbox' type='text' id='cf_tickerWidth' name='cf_tickerWidth' value='100' size='3' maxlength='3'onBlur='checkData(this)' />and this is my javascript:
Code: Select all
function checkData(dataName){
switch(dataName.name){
case 'cf_tickerWidth':
try {
if (!dataName.value){
throw new Error('The Ticker Width cannot be blank.');
} else if (dataName.value <= 0 || dataName.value > 100){
throw new Error('The Ticker Width needs to be between 1 and 100.');
}
}
catch (errMsg){
alert(errMsg.message)
dataName.name.focus();
dataName.name.select();
}
break
default:
alert('It didn\'t work ' + dataName.name + ' ' + dataName.value);
}
}The alert box will display but it will not focus on the field or select the data within. The error I get in my javascript console is "dataName.name.focus is on a function" .
I have tried putting dataName.name into a var (i.e. var testName = dataName.name) and use it that way with no luck. Soooo what am I doing wrong? Thanks