HI team,
How to restrict Text in Text input field using javascript. i have tried this
$(function() { $("$parameters.WidgestName").dxTextBox({ maxLength: 10, setAttribute:typeof(Number) });});
it was not working could you please help me on this.
Thanks,
Akash.
Hello Akash,Please try this : Regax method https://www.outsystems.com/forums/discussion/78790/allow-user-only-put-numbers-on-input-widget/Let me know, if this works for youThanks and Regards,Akshay Deshpande
thanks for the reply Akshay i will try now
Applied its not working
Hey Akash,It is possible to used forge component If yes used this : Input Mask reactI have attached the Demo Link and OML for your referenceNote : In that go with the mask textThanks and Regards,Akshay Deshpande
@Akash Gunupudi this solution helps for you ?
Hi @Akash GunupudiPlease check the below links:https://www.outsystems.com/forums/discussion/84658/how-to-restrict-user-only-to-enter-phonenumber/#
https://www.outsystems.com/forums/discussion/75877/phone-no-regex/#https://www.outsystems.com/forums/discussion/78790/allow-user-only-put-numbers-on-input-widget/#
https://www.outsystems.com/forums/discussion/75255/phone-number-validation/#
RegardsKrishnanand Pathak
You can also try to use the below component:
https://www.outsystems.com/forge/component-overview/14672/restrict-characters
Hi Akash Gunupudi,
You can use the slice method in javascript.
var input = document.getElementById($parameters.WidgestName);
inputId.value = inputId.value.slice(0, 10);
or
Write this code in Onready's JavaScript node
input.addEventListener("input", function() {
input.value = input.value.slice(0, 10);
})
Hello Akash,
Kindly use this in javascript and use this during oninput of your input box.
var inputid= document.activeElement.id;
document.getElementById(inputid).value =document.getElementById(inputid).value
.replace(/[^0-9]/gi,'');
This will help you in real-time.
Regards,
Dinesh Kumar.
Hey,
Create KeyPress event for input and inside keypress event use javascript like below.function ABC(txt,event){
var a=event.keycode||event.which;
if(a>47 && a<58){
//If pressed key is number then it will allow
return true;
}else{
//If pressed key is not number then it will not allow to press key
event.preventDefault();
}
return ABC($parameter.widgetId,event);
Hope this will help you.
Thanks
Yogesh
Thank @Yogesh Javir it worked for me.
Hi @Akash Gunupudi, As @Krishnanand Pathak already suggested, you can use Restrict Characters, our forge component. You can check the demo to see that it works and its documentation to see how easy it is to use.To test the demo, just add '0-9' in the input labeled Regular Expression without the quotation marks, and in the input labeled Input you can see that you can only type integers.ThanksGitansh Anand
Hello
You can do that by preventing those keys which you don't want, I have created a sample for you let me know if this helps you.
https://personal-ejuytnht.outsystemscloud.com/RandomName/NumberInput
I hope this helps.
Thanks & RegardsTousif Khan
Hi Akash,
Kindly use this below JS in Oninput event handler of the input box.
var inputid = document.activeElement.id;
document.getElementById(inputid).value = document.getElementById(inputid).value.replace(/[^\d]/g, '');
You can't find oninput event in the list, You need to type on it.