$('form').on('submit', function() {
var info = $('#infoSubmit');
var inName = $('input#name-of-company');
var inNif = $('input#nif');
var inNameReg = /^[A-Za-z0-9 ]{2,80}$/;
if ( !inNameReg.test(inName.val()) ) {
info.text('please enter a valid name');
inName.addClass('wrongInput');
inName.focus();
} else {
(...)
inName.value.replace(/^\s+|\s+$/g, '');
if (!inName.value.match(/^\S.{0,78}\S$/) {
alert('please enter a valid name');
}
var inNameReg = /\S.{0,78}\S/;
Open in new window
\S matches for everything expect whitespaces.
If you trim your companyname using this command before:
Open in new window