Disable possibility to paste floating characters to Input number fieldHow do I convert a float number to a whole number in JavaScript?HTML-encoding lost when attribute read from input fieldDisable/enable an input with jQuery?How to deal with floating point number precision in JavaScript?How do I check that a number is float or integer?Set the value of an input fieldHow can I limit possible inputs in a HTML5 “number” element?How do I get the value of text input field using JavaScript?Is there a float input type in HTML5?Is it possible to apply CSS to half of a character?

How would armour (and combat) change if the fighter didn't need to actually wear it?

Running code generated in realtime in JavaScript with eval()

Is there a name for the technique in songs/poems, where the rhyming pattern primes the listener for a certain line, which never comes?

How can I shoot a bow using Strength instead of Dexterity?

What are the advantages of this gold finger shape?

Are there any cons in using rounded corners for bar graphs?

What is the hottest thing in the universe?

Bringing Power Supplies on Plane?

Why does this Jet Provost strikemaster have a textured leading edge?

Why do so many people play out of turn on the last lead?

Sword-and-sorcery flick from the 80s with a magic scarf that saves the hero's life

What can Amex do if I cancel their card after using the sign up bonus miles?

Can anybody tell me who this Pokemon is?

Is there a word for returning to unpreparedness?

What is the prop for Thor's hammer (Mjölnir) made of?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?

Setting up a Mathematical Institute of Refereeing?

Is the Microsoft recommendation to use C# properties applicable to game development?

How can I communicate my issues with a potential date's pushy behavior?

What's the relationship betweeen MS-DOS and XENIX?

Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?

Why won't the Republicans use a superdelegate system like the DNC in their nomination process?

What is the most difficult concept to grasp in Calculus 1?

What modifiers are added to the attack and damage rolls of this unique longbow from Waterdeep: Dragon Heist?



Disable possibility to paste floating characters to Input number field


How do I convert a float number to a whole number in JavaScript?HTML-encoding lost when attribute read from input fieldDisable/enable an input with jQuery?How to deal with floating point number precision in JavaScript?How do I check that a number is float or integer?Set the value of an input fieldHow can I limit possible inputs in a HTML5 “number” element?How do I get the value of text input field using JavaScript?Is there a float input type in HTML5?Is it possible to apply CSS to half of a character?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have an issue, when trying to disable paste floating number for <input type='number' />. I disable + - e E . onKeyDown but how to disable it on onPaste? For now I can only use e.preventDefault() for onPatste to disable at whole. How to disable only + - e E .



 <CutomInputField
required
type='number'
inputProps=
min: '1',
max: '100',
autoComplete: 'off',

onKeyDown=e =>preventFloatingPointNumber(e)
onPaste=e =>
e.preventDefault()
// preventFloatingPointNumber(e) //does not work such way


/>

// 'left arrow', 'up arrow', 'right arrow', 'down arrow',
const arrowsKeyCodes = [37, 38, 39, 40];
// 'numpad 0', 'numpad 1', 'numpad 2', 'numpad 3', 'numpad 4', 'numpad 5',
'numpad 6', 'numpad 7', 'numpad 8', 'numpad 9'
const numPadNumberKeyCodes = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105];

const preventFloatingPointNumber = e => {
// allow only [0-9] number, numpad number, arrow, BackSpace, Tab
if ((e.keyCode < 48 && !arrowsKeyCodes.includes(e.keyCode) || e.keyCode > 57 &&
!numPadNumberKeyCodes.includes(e.keyCode)) &&
!(e.keyCode === 8 || e.keyCode === 9))
e.preventDefault()









share|improve this question



















  • 1





    Why not run a convert a floating point to an integer in onPaste ?

    – Paul Redmond
    Mar 27 at 11:46











  • onPaste how you get a value you paste on input field number?

    – Palaniichuk Dmytro
    Mar 27 at 11:54











  • @PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

    – Vladimir Bogomolov
    Mar 27 at 11:57











  • clipboardData always null ethier I use ctrl + v or right click moust paste option

    – Palaniichuk Dmytro
    Mar 27 at 12:01






  • 1





    const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

    – Palaniichuk Dmytro
    Mar 27 at 12:18

















0















I have an issue, when trying to disable paste floating number for <input type='number' />. I disable + - e E . onKeyDown but how to disable it on onPaste? For now I can only use e.preventDefault() for onPatste to disable at whole. How to disable only + - e E .



 <CutomInputField
required
type='number'
inputProps=
min: '1',
max: '100',
autoComplete: 'off',

onKeyDown=e =>preventFloatingPointNumber(e)
onPaste=e =>
e.preventDefault()
// preventFloatingPointNumber(e) //does not work such way


/>

// 'left arrow', 'up arrow', 'right arrow', 'down arrow',
const arrowsKeyCodes = [37, 38, 39, 40];
// 'numpad 0', 'numpad 1', 'numpad 2', 'numpad 3', 'numpad 4', 'numpad 5',
'numpad 6', 'numpad 7', 'numpad 8', 'numpad 9'
const numPadNumberKeyCodes = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105];

const preventFloatingPointNumber = e => {
// allow only [0-9] number, numpad number, arrow, BackSpace, Tab
if ((e.keyCode < 48 && !arrowsKeyCodes.includes(e.keyCode) || e.keyCode > 57 &&
!numPadNumberKeyCodes.includes(e.keyCode)) &&
!(e.keyCode === 8 || e.keyCode === 9))
e.preventDefault()









share|improve this question



















  • 1





    Why not run a convert a floating point to an integer in onPaste ?

    – Paul Redmond
    Mar 27 at 11:46











  • onPaste how you get a value you paste on input field number?

    – Palaniichuk Dmytro
    Mar 27 at 11:54











  • @PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

    – Vladimir Bogomolov
    Mar 27 at 11:57











  • clipboardData always null ethier I use ctrl + v or right click moust paste option

    – Palaniichuk Dmytro
    Mar 27 at 12:01






  • 1





    const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

    – Palaniichuk Dmytro
    Mar 27 at 12:18













0












0








0








I have an issue, when trying to disable paste floating number for <input type='number' />. I disable + - e E . onKeyDown but how to disable it on onPaste? For now I can only use e.preventDefault() for onPatste to disable at whole. How to disable only + - e E .



 <CutomInputField
required
type='number'
inputProps=
min: '1',
max: '100',
autoComplete: 'off',

onKeyDown=e =>preventFloatingPointNumber(e)
onPaste=e =>
e.preventDefault()
// preventFloatingPointNumber(e) //does not work such way


/>

// 'left arrow', 'up arrow', 'right arrow', 'down arrow',
const arrowsKeyCodes = [37, 38, 39, 40];
// 'numpad 0', 'numpad 1', 'numpad 2', 'numpad 3', 'numpad 4', 'numpad 5',
'numpad 6', 'numpad 7', 'numpad 8', 'numpad 9'
const numPadNumberKeyCodes = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105];

const preventFloatingPointNumber = e => {
// allow only [0-9] number, numpad number, arrow, BackSpace, Tab
if ((e.keyCode < 48 && !arrowsKeyCodes.includes(e.keyCode) || e.keyCode > 57 &&
!numPadNumberKeyCodes.includes(e.keyCode)) &&
!(e.keyCode === 8 || e.keyCode === 9))
e.preventDefault()









share|improve this question














I have an issue, when trying to disable paste floating number for <input type='number' />. I disable + - e E . onKeyDown but how to disable it on onPaste? For now I can only use e.preventDefault() for onPatste to disable at whole. How to disable only + - e E .



 <CutomInputField
required
type='number'
inputProps=
min: '1',
max: '100',
autoComplete: 'off',

onKeyDown=e =>preventFloatingPointNumber(e)
onPaste=e =>
e.preventDefault()
// preventFloatingPointNumber(e) //does not work such way


/>

// 'left arrow', 'up arrow', 'right arrow', 'down arrow',
const arrowsKeyCodes = [37, 38, 39, 40];
// 'numpad 0', 'numpad 1', 'numpad 2', 'numpad 3', 'numpad 4', 'numpad 5',
'numpad 6', 'numpad 7', 'numpad 8', 'numpad 9'
const numPadNumberKeyCodes = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105];

const preventFloatingPointNumber = e => {
// allow only [0-9] number, numpad number, arrow, BackSpace, Tab
if ((e.keyCode < 48 && !arrowsKeyCodes.includes(e.keyCode) || e.keyCode > 57 &&
!numPadNumberKeyCodes.includes(e.keyCode)) &&
!(e.keyCode === 8 || e.keyCode === 9))
e.preventDefault()






javascript reactjs validation input ecmascript-6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 11:40









Palaniichuk DmytroPalaniichuk Dmytro

7181 gold badge15 silver badges34 bronze badges




7181 gold badge15 silver badges34 bronze badges










  • 1





    Why not run a convert a floating point to an integer in onPaste ?

    – Paul Redmond
    Mar 27 at 11:46











  • onPaste how you get a value you paste on input field number?

    – Palaniichuk Dmytro
    Mar 27 at 11:54











  • @PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

    – Vladimir Bogomolov
    Mar 27 at 11:57











  • clipboardData always null ethier I use ctrl + v or right click moust paste option

    – Palaniichuk Dmytro
    Mar 27 at 12:01






  • 1





    const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

    – Palaniichuk Dmytro
    Mar 27 at 12:18












  • 1





    Why not run a convert a floating point to an integer in onPaste ?

    – Paul Redmond
    Mar 27 at 11:46











  • onPaste how you get a value you paste on input field number?

    – Palaniichuk Dmytro
    Mar 27 at 11:54











  • @PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

    – Vladimir Bogomolov
    Mar 27 at 11:57











  • clipboardData always null ethier I use ctrl + v or right click moust paste option

    – Palaniichuk Dmytro
    Mar 27 at 12:01






  • 1





    const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

    – Palaniichuk Dmytro
    Mar 27 at 12:18







1




1





Why not run a convert a floating point to an integer in onPaste ?

– Paul Redmond
Mar 27 at 11:46





Why not run a convert a floating point to an integer in onPaste ?

– Paul Redmond
Mar 27 at 11:46













onPaste how you get a value you paste on input field number?

– Palaniichuk Dmytro
Mar 27 at 11:54





onPaste how you get a value you paste on input field number?

– Palaniichuk Dmytro
Mar 27 at 11:54













@PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

– Vladimir Bogomolov
Mar 27 at 11:57





@PalaniichukDmytro you can use e.clipboardData.getData('text/plain')

– Vladimir Bogomolov
Mar 27 at 11:57













clipboardData always null ethier I use ctrl + v or right click moust paste option

– Palaniichuk Dmytro
Mar 27 at 12:01





clipboardData always null ethier I use ctrl + v or right click moust paste option

– Palaniichuk Dmytro
Mar 27 at 12:01




1




1





const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

– Palaniichuk Dmytro
Mar 27 at 12:18





const pastedData = e.clipboardData.getData('text/plain') if (isNaN(pastedData)) e.preventDefault() -works for me thanks

– Palaniichuk Dmytro
Mar 27 at 12:18












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376325%2fdisable-possibility-to-paste-floating-characters-to-input-number-field%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376325%2fdisable-possibility-to-paste-floating-characters-to-input-number-field%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?