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 Postlook 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
Reply to this topic
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.