I am building a web application with NodeJS and express. I am having a form that submits a POST request on submission. How do i validate the "phone" input so that phone number is 10 digits.
<form action="/books" method="POST" enctype="multipart/form-data">
<input class="form-control" type="text" name="user[name]" placeholder="name" required>
<input class="form-control" type="number" name="user[phone]" placeholder="phone" required>
<button>Submit</button>
</form>
The user must not be able to submit if the phone number is invalid.
Any help is very much appreciated