Which text field onFocus called the function?
Hi,
Question:
Is there something that can be passed to a Javascript function that tells the function which element index called it?
I'm doing some date/time verification with Javascript.
DateTime2 must be after DateTime1 and DateTime3 must be after DateTime2. DateTime1 comes from a database.
A onFocus in DateTime3 calls the function to verify that DateTime2 date is after DateTime1. Likewise an onFocus in the field after DateTime3 verifies DateTime2 and DateTime3.
Code:
strHtml=strHtml & "function check_isDate(day,month,year,x,what)"
strHtml=strHtml & "{"
strHtml=strHtml & " if (!isDate(day,month,year))"
strHtml=strHtml & " {"
strHtml=strHtml & " alert(""Invalid "" + what);"
strHtml=strHtml & " document.CallInfo.elements[x-3].focus();"
strHtml=strHtml & " }"
strHtml=strHtml & "}"
Right now I'm hardcoding an element number (x in the above) in the function call.The purpose for this is so I can set the focus back to the field that contained the error.
I hope this makes sense.
Al.