How do I make an input box accept numbers only?

I’m glad I was suspicious of that function.

Your enforcePositiveInteger() is working, thanks. I need to figure out that regex though. I think I would much rather use what’s in the link you posted:

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

coupled with some simpler code (I don’t like regular expressions because I don’t understand them, yet). But I’m too much of a beginner to know how to use css code. I threw it at the bottom of my style.css file and nothing happened.

@Kevin I’m sure what you say is true, however, as a beginner I can tell you that there is a gap in the ‘how-to’ out there between html and p5.js. So, I have found code out there in html that claims to do what I want, however, it is very unclear to me how to implement it in p5.js. This is one of the reasons I was looking for all the methods that are available to an object yesterday, as you might remember.

1 Like