The way you're going...
Give your elements an id as well (it can be the same as the name).
And use getElementById() instead.
Also remove () from .value()
<form action="<liferay-portlet:actionURL name="saveForm" />"
id="<portlet:namespace />sampleForm"
method="post" enctype="multipart/form-data" name="<portlet:namespace />sampleForm">
<aui:input name="firstName" id="firstName" /> /* this is autocomplete field*/
<aui:input name="lastName" id="lastName" onChange="myFunction()"/>
.
.
.
.
</form>
<script type="text/javascript" language="javascript">
function myFunction(){
alert("in----------");
alert(document.getElementById("firstName").value);
}
</script>