form action=“指定的页面”和“指定页面”的代码,
验证名字,密码不能为空,
如何处理登陆用户密码匹配的代码,
多谢各位大侠!

解决方案 »

  1.   


    formName=form表单名称
     if (document.formName.userName.value == ""){
    alert("用户名为空");
    return;
    }
    if (document.formName.userPwd.value == ""){
    alert("用户密码为空");
    return;
    }用户名和密码匹配,可以用equals进行比较。
    如果是数据库的,可以进行查询 (select count(*) from userInfo where username = 'abc' and userpwd = '123456')返回的count = 1 登陆成功,如果是0就失败了。当然数据不能重复。
      

  2.   

    formName=form表单名称
     if (document.formName.userName.value == ""){
    alert("用户名不能为空");
    return  false;
    }
    if (document.formName.userPwd.value == ""){
    alert("用户密码不能为空");
    return  false;
    }
    以上是客户端的js验证,你也可做后台的验证,代码如下:
    if(formbean.getUsername==null||formbean.getUsername.equals("")){
    ActionMessage message=new ActionMessage("XXXXX";"xxxx");
     
    return ;
    }if(formbean.Password==null||formbean.getPassword.equals("")){
    ActionMessage message=new ActionMessage("XXXXX";"xxxx");
     return;}