JSFiddle - React, Tailwind, and code Playground
HTML
<form name="myForm" method="POST">
<input type="text" name="isbn" />
<button>Submit</button>
</form>
<p id="ouput"></p>
JavaScript
var form = document.forms.myForm,
el = form.elements;
var isbnValidator = function(isbn) {
return isbn.replace(/[^\dx]/ig, '').split('').map(function(el) {
return /x/i.test(el) ? 10 : parseInt(el);
}).reduce(function(prev, cur, idx, arr) {
return prev * (idx === 1 ? arr.length : 1) + (arr.length - idx) * cur;
}) % 11 === 0;
}
form.onsubmit = function() {
alert(isbnValidator(el.isbn.value));
return false;
}