You need to sign in to do that
Don't have an account?
syntax to accept only 10 digit number in inputText Field and should't contain any character please help me with this (Without Javascript)
syntax to accept only 10 digit number in inputText Field and should't contain any character please help me with this (Without Javascript)
Greetings to you!
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Try this code:
Component: CheckInptNumber
<aura:component >
<aura:attribute name="EnterValue" type="Integer" />
<lightning:input label="" type="text" placeholder="Enter your 10-digit order number(eg:3751234531)" maxlength="10" onblur ="{!c.checkValue}" aura:id="enterNumber" pattern="[0-9]*"/>
<div style="color: red;">
<ui:outputText value="" aura:id="customeError" />
</div>
</aura:component>
For Showing custome error you can use this:
helper:
({
checkValue : function(component, event, helper) {
var Number = component.find("enterNumber").get("v.value");
console.log("-----" + Number);
if( isNaN(Number) || Number.length != 10)
{
component.find("customeError").set("v.value", "This cannot be null or text, You must enter number of 10 digits.");
component.set("v.EnterValue", null);
}
else
{
component.find("customeError").set("v.value", " ");
component.set("v.EnterValue", Number);
}
}
})
Application: CheckInptNumberApp
<aura:application >
<c:CheckInptNumber/>
</aura:application>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
But it's not working, I didn't use the components in my code. My number field's data type is PHONE.