I want to reuse a script; for that I need to pass the input field name to the script. I added the '+' but it does not work. The script and form would look something like this:
<script>
function checkLength(fieldName){
if (document.myForm.+fieldName+.value.length > 400){
alert("Your text is too long, it has been truncated."
document.myForm.+fieldName+.value = document.myForm.+fieldName+.value.substr(0,400)
}
}
</script>
<form name="myForm">
<textarea name="A2a" cols="95" rows="3" tabindex="13" wrap="soft" onBlur="checkLength(A2a)">
<script>
function checkLength(fieldName){
if (document.myForm.+fieldName+.value.length > 400){
alert("Your text is too long, it has been truncated."
document.myForm.+fieldName+.value = document.myForm.+fieldName+.value.substr(0,400)
}
}
</script>
<form name="myForm">
<textarea name="A2a" cols="95" rows="3" tabindex="13" wrap="soft" onBlur="checkLength(A2a)">