[SalesForce] How to display old and new values in Lightning field

I have multiple lightning input field and my requirement is to display the old and changed values of the field in separate view. I am newbie to lightning and I am struggling to figure out the concept. Any help highly appreciated.

I started with one field and I have alert box to show the old and new value.


 <aura:component implements="force:appHostable">
    <aura:attribute name="expenseName" type="String" default="My Expense"/>
     <aura:attribute name="expenseName1" type="String" default="My Expense1"/>
    <aura:handler name="change" value="{!v.expenseName}" action="{!c.expenseNameChanged}"/> 
    <aura:handler name="change" value="{!v.expenseName1}" action="{!c.expenseNameChanged}"/>    

    <ui:inputText label="Expense Name" value="{!v.expenseName}"/>
    <ui:inputText label="Expense Name1" value="{!v.expenseName1}"/>


    expenseNameChanged : function(component, event, helper) {
        var newValue = event.getParam("value");
        var oldValue = event.getParam("oldValue");
        alert("Expense name changed from '" + oldValue + "' to '" + newValue + "'");

Best Answer

Use onkeypress to get old value on this event it will return the value before pressing keys and to get new value please use onkeyup then it will give new value.

So you need to use two events onkeypress and onkeyup and it will work. thank you