Form Checkging JS For Register
const blanks = new RegExp(/^\s*$/) function blnk(x) { return x.match(blanks) != null; } function subchk() { var form = document.getElementById("regform"); var err = ''; if(blnk(form.userid.value)) err = 'No userid.'; else if(blnk(form.username.value)) err = 'No user human name.'; else if(blnk(form.pwd1.value)) err = 'Please enter a password'; else if(blnk(form.pwd2.value)) err = 'Please confirm your password'; else if(form.pwd1.value != form.pwd2.value) err = 'Passwords do not match.'; if(err == '') { return true; } else { // Make the error mesage. We'll have to add the // the div for it var errarea = document.getElementById("err"); if(errarea == null) { errarea = document.createElement('div') document.getElementsByTagName("body")[0].appendChild(errarea); errarea.setAttribute("id", "err"); errarea.setAttribute("class", "err"); } errarea.textContent = err; return false; } }