I had tried to follow this solution but it does not seem to work for lightning:inputField. Basically I want to stop negative values from being entered in the field. I have tried the solutions below but it doesn't seem to work. Is it possible to create validations on inputFields?

  <span onkeypress={!c.checkValue}">
  <lightning:inputField fieldName="Withdrawal_Amount__c" aura:id"wAmount" variant="label-hidden"/>

 checkValue : function(component, event, helper){
      if(!((event.keyCode > 95 && event.keyCode < 106)
  || (event.keyCode > 47 && event.keyCode < 58) 
  || event.keyCode == 8)) {
    return false;


<lightning:inputField fieldName="Withdrawal_Amount__c" aura:id"wAmount" 
variant="label-hidden" onchange="validity.valid||(value='');"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.