I've to make a program in javascript which would take an integer from the user it can be negative or positive but if user insert a decimal number or a character so this program should display an error message.
Can anyone help me jow to do it.
Katik14 -2 Newbie Poster
Troy III commented: An original reusable & efficient code has been given to you - you need to say "THANK YOU!" and mark your thread as "Solved!" -2
Recommended Answers
Jump to Post— Member #905211look at using regular expressions for this.
var regex = /[0-9]+/ig; if(!regex.test(valueTestingAgainst)){ alert('you have an error'); }I have not tested this code. If it doesn't work, look up how to use regular expressions in javascript, then look for a regular expression that works for your …
All 2 Replies
Member #905211
Troy III 272 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.