Jithu Jithu - 2 months ago 12
PHP Question

How to find which input field is modified?

I have couple of input field and values in them. This is projected to the user.
The user can modify these values and submit them.
When submitted, I need to check which input field is modified.

I can compare the previous fields and current fields and check. But I am trying to find more optimized way to do this.
I can use javascript, php, jquery and html tricks

Answer
<input id="input1" value="someValue" type="text">
<input id="input2" value="someValue" type="text">

Script:

$('input').on('change',function(){
  var id = $(this).attr('id');
  alert("input field is modified : ID = " + id);
});