Нано Компьютеры

nano-computers.ru/Public/home/js/check.js

nano-computers.ru/Public/home/js/check.js is a JavaScript file used by the website nano-computers.ru. The purpose of the file is to perform various checks on user input before submitting it to the website's server.

File Structure

The check.js file is structured as follows:

function checkForm() {
    // code to perform checks on form inputs
}

function checkEmail(email) {
    // code to check that email is valid
}

function checkPhone(phone) {
    // code to check that phone number is valid
}

The checkForm function is called when the user submits a form on the website, and it calls the checkEmail and checkPhone functions to validate the email address and phone number, respectively.

Email Validation

The checkEmail function uses a regular expression to check that the email address is valid. The regular expression used is:

var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

This regular expression checks that the email address has the correct format, with a username, followed by an "@" symbol, followed by a domain name, and a top-level domain.

If the email address is not valid, the checkEmail function returns false, which causes the checkForm function to prevent the form from being submitted and displays an error message to the user.

Phone Number Validation

The checkPhone function checks that the phone number is valid by using a regular expression to check that the number only contains digits and is either 10 or 11 characters long. The regular expression used is:

var phoneRegex = /^\d{10,11}$/;

If the phone number is not valid, the checkPhone function returns false, which causes the checkForm function to prevent the form from being submitted and displays an error message to the user.

Conclusion

In conclusion, the check.js file is an important part of the nano-computers.ru website, ensuring that user input is validated before being submitted to the website's server. The file includes functions to validate email addresses and phone numbers, and if the input is determined to be invalid, the check.js file prevents the form from being submitted and displays an error message to the user.