Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 关于验证确认密码和纯字母文本,是否正确_Javascript - Fatal编程技术网

Javascript 关于验证确认密码和纯字母文本,是否正确

Javascript 关于验证确认密码和纯字母文本,是否正确,javascript,Javascript,验证确认密码和字母文本是否正确。它不起作用了,请帮忙。谢谢 function validation(password, confirmpassword) { var password = document.form.password.value; var confirmpassword = document.form.confirmpassword.value; if (password.length <= 6) { alert("pas

验证确认密码和字母文本是否正确。它不起作用了,请帮忙。谢谢

function validation(password, confirmpassword) {
    var password = document.form.password.value;
    var confirmpassword = document.form.confirmpassword.value;

    if (password.length <= 6) {
        alert("password must be more thank 6 characters long");
        return false;
    }
    if (password.value !== confirmpassword.value)
        alert("password should match");
    return false;
}

function allLetter(inputtxt) {
    var letters = /^[a-z]*$/i;
    if (!inputtxt.value.match(letters)) {
        alert("Please input letters only");
    }
}
功能验证(密码、确认密码){
var password=document.form.password.value;
var confirmpassword=document.form.confirmpassword.value;

如果(password.length您可以这样做:

功能验证(事件){
event.preventDefault();
var password=document.querySelector(“.password”).value;
var confirmpassword=document.querySelector(“.confirmpassword”).value;

if(password.length
if(password.value!==confirmpassword.value)
->
if(password!==confirmpassword)
(您已经在函数开始时提取了值)。您还应该在
警报
返回
周围放上大括号。最后,添加一个
返回true;
您正在传递密码和确认为参数的值,并且仍然在前两行声明它。