we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "javascript check if number is hexadecimal"
Sofia
30 Jul 2017
1var re = /[0-9A-Fa-f]{6}/g;
2var inputString = 'AABBCC';
3
4if(re.test(inputString)) {
5    alert('valid hex');
6} else {
7    alert('invalid');
8}
9
10re.lastIndex = 0; // be sure to reset the index after using .text()
11