I think this isn't right way. Maybe you can suggest something about error-displaying in error-container which fill in JS.index.html<!DOCTYPE html><html lang=en><head>    <meta charset=UTF-8>    <title>Registration</title>    <link rel=stylesheet href=css/style.css></head><body><div class=display>    <h1>Registration form</h1>    <form>        <div id=error-container></div>        <table>            <tr>                <td><label class=text-label for=login>Login:</label></td>                <td><input class=text name=login type=text id=login></td>            </tr>            <tr>                <td><label class=text-label for=password>Password:</label></td>                <td><input class=text name=password type=password id=password></td>            </tr>            <tr>                <td><label class=text-label for=password2>Confirm password:</label></td>                <td><input class=text name=password2 type=password id=password2></td>            </tr>            <tr>                <td><label class=text-label for=email>Email:</label></td>                <td><input class=text name=email type=text id=email></td>            </tr>            <tr>                <td>                    <label class=text-label for=tel>Phone number:</label></td>                <td><input class=text type=tel id=tel name=tel placeholder=380938866772></td>            </tr>            <tr>                <td></td>                <td><input id=registration-button class=send-button type=submit value=Registration></td>            </tr>        </table>        <br/>    </form></div><script src=js/script.js></script></body></html>errorDisplay.jsfunction ErrorDisplay(containerID) {    this.container = document.getElementById(containerID);    this.createDisplayingBlock();    this.display = none;    this.setDisplaying(this.display);}ErrorDisplay.prototype.setContainerElement = function (element) {    this.container = element;};ErrorDisplay.prototype.setDisplaying = function (value) {    this.container.style.display = value;};ErrorDisplay.prototype.toggleDisplaying = function () {    if (this.display == none) {        this.setDisplaying();    }    else {        this.setDisplaying(none);    }};ErrorDisplay.prototype.createDisplayingBlock = function () {    this.errorBlock = document.createElement('div');    this.errorBlock.className = error;    this.container.appendChild(this.errorBlock);};ErrorDisplay.prototype.show = function (message) {    this.errorBlock.innerHTML = message;    this.setDisplaying();};ErrorDisplay.prototype.hide = function () {    this.setDisplaying(none);};ErrorDisplay.prototype.deleteBlock = function () {    this.container.removeChild(this.errorBlock);};module.exports = ErrorDisplay;inputChecker.jsfunction InputChecker(elem, minSize, maxSize) {    this.elem = elem;    this.elemTextValue = elem.value;    this.minSize = minSize || 0;    this.maxSize = maxSize || Infinity;}InputChecker.prototype.isLessMinLength = function(){    return this.elemTextValue.length < this.minSize;};InputChecker.prototype.isBiggerMaxLength = function(){    return this.elemTextValue.length > this.maxSize;};InputChecker.prototype.isMatch = function(reg) {    var res = reg.test(this.elemTextValue);    return res;};InputChecker.prototype.compareValuesWithElem = function(comparedElem) {    this.comparedElem = comparedElem;    return this.elemTextValue != this.comparedElem.value;};module.exports = InputChecker;formValidation.jsvar InputChecker = require('./InputChecker');var ErrorDisplay = require('./ErrorDisplay');function FormValidation() {    this.err = new ErrorDisplay(error-container);}FormValidation.prototype.validate = function (event) {    event.preventDefault();    if (this.checkLoginInput() && this.checkPasswordInput() && this.checkEmailInput()) {        this.err.hide();        alert(done);    }};FormValidation.prototype.checkLoginInput = function () {    var loginElement = document.getElementById(login);    var reg = /^[a-zA-Z]{2,}(_?|-?){1}?[a-zA-Z]+(\d+)?$/i;    var login = new InputChecker(loginElement, 3, 30);    if (login.isLessMinLength()) {        this.err.show(min);        return false;    }    if (login.isBiggerMaxLength()) {        this.err.show(max);        return false;    }    if (reg && !login.isMatch(reg)) {        this.err.show(format);        return false;    }    return true;};FormValidation.prototype.checkPasswordInput = function () {    var passwordElement = document.getElementById(password);    var confirmPasswordElement = document.getElementById(password2);    var reg = /^[a-zA-Z]{2,}(_?|-?){1}?[a-zA-Z]+(\d+)?$/i;    var passwordInput = new InputChecker(passwordElement, 3, 30);    if (passwordInput.isLessMinLength()) {        this.err.show(min);        return false;    }    if (passwordInput.isBiggerMaxLength()) {        this.err.show(max);        return false;    }    if (reg && !passwordInput.isMatch(reg)) {        this.err.show(format);        return false;    }    if (passwordInput.compareValuesWithElem(confirmPasswordElement)) {        this.err.show(password doesnt equals);        return false;    }    return true;};FormValidation.prototype.checkEmailInput = function () {    var emailElement = document.getElementById(email);    var reg = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/i;    var email = new InputChecker(emailElement, 3, 30);    if (email.isLessMinLength()) {        this.err.show(min);        return false;    }    if (email.isBiggerMaxLength()) {        this.err.show(max);        return false;    }    if (reg && !email.isMatch(reg)) {        this.err.show(format);        return false;    }    return true;};module.exports = FormValidation;And the run js file script.jsvar FormValidation = require(./FormValidation);var registrationButton = document.getElementById(registration-button);var validation = new FormValidation();registrationButton.addEventListener(click, validation.validate.bind(validation));
Checking a user registration form before sending
javascript;html;validation;node.js