function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
simon chaosimon chao 

prevent page from loading if error occurred

Hi, I currently have the code below
<td data-label="TESTING"><lightning:input type="number" min="0" label="" name=" " value="{!v.testint.test__c}"/></td>
I don't want any decimals, so if there is a decial a error will show up, as seen in the pic below 
User-added image
I also have a Next button at the bottom of the page. Is it possible to make the page stay on the current page when a error such as the above shows up? And only allow the page to go to the next section when the number have been changed from a decimal to a whole number, or when there are no errors shown. 
 
Best Answer chosen by simon chao
simon chaosimon chao
i added in a if function for the function that dictates the page redirect, and it works. [solved] 

All Answers

Raj VakatiRaj Vakati
Try this code 
 
<aura:if isTrue="{!v.testint.test__c gt 1}">

<td data-label="TESTING"><lightning:input type="number" min="0" label="" name=" " value="{!v.testint.test__c}"/></td>

</aura:if>

 
simon chaosimon chao
It still goes to the next page. So I wrote 

<aura:if isTrue="{!v.testint.test__c gt 1}">
 <tr class="rowTable">   
       <td data-label="TESTING"><lightning:input type="number" min="0" label="" name=" " value="{!v.testint.test__c}"/></td>
       <td data-label="TESTING"><lightning:input type="number" min="0" label="" name=" " value="{!v.testint1.test__c}"/></td>
       <td data-label="TESTING"><lightning:input type="number" min="0" label="" name=" " value="{!v.testint2.test__c}"/></td>
</tr>
</aura:if>

I should split up the lightning inputs into separate aura sections right? Because I currently have them in a row. 
I tried with just one lightning input but that doesn't work either.
simon chaosimon chao
or  better if I can have a error message that pops up every time a user inputs a decimal number for the lightning input. Is this possible? 
can i add a onclick="{!doAction}" within the lightning input? and from my controller side i will have 

doAction :function(cmp)
{
     check for whole number, if not display error?
}
simon chaosimon chao
i added in a if function for the function that dictates the page redirect, and it works. [solved] 
This was selected as the best answer