I have auto-complate code that fill the text field and also fill hidden field with the row ID I would like that when the ID field is not empty than the form ACTION will change to another url. Again - the contactID field is something that automatically get filled
HTML
<form method="post" action="index.php?page=contacts" class="quick_search">
<input type="text" name="fNameHe" value="<?PHP echo $_POST['fNameHe'] ?>" />
<input type="hidden" name="contactID" value="" id="contactID" />
<span id="ajax_response_contact" class='ajax_response'></span>
JS:
$("#contactID").on('change keyup copy paste cut', function() { // <- not working
var contactID = $( "#contactID" ).val();
alert(contactID);
var action = $(this).val() != "" ? "contactPage=contactID="+contactID : "contacts";
$("#contactID").parents('form').attr("action", action);
});