小编try*_*est的帖子

返回JavaScript函数中的布尔值

我正在进行客户端表单验证以检查密码是否匹配.但验证功能总是返回undefined.

function validatePassword(errorMessage)
{
   var password = document.getElementById("password");
   var confirm_password = document.getElementById("password_confirm");

   if(password.value)
   {
      // Check if confirm_password matches
      if(password.value != confirm_password.value)
      {
         return false;
      }
   }
   else
   {
      // If password is empty but confirm password is not
      if(confirm_password.value)
      {
         return false;
      }
   }
   return true;
}
Run Code Online (Sandbox Code Playgroud)

请注意,validatePassword从Form对象的成员函数调用.

function Form(validation_fn)
{
   // Do other stuff
   this.submit_btn = document.getElementById("submit");
   this.validation_fn = validation_fn;
}

Form.prototype.submit = funciton()
{
   var result;
   if(this.validation_fn)
   {
      result = this.validation_fn();
   }

   //result …
Run Code Online (Sandbox Code Playgroud)

javascript

19
推荐指数
2
解决办法
13万
查看次数

在mercurial中跨子子仓库移动文件

有没有人知道如何在保留文件历史记录的同时跨文件移动文件

我在用 hg mv /Product/common/modules/sub-repo1/scripts/filename /Product/common/modules/sub-repo2/scripts/filename

Product是shell水平回购,sub-repo1以及sub-repo2是次回购

它抛出错误中止/Product/common/modules/sub-repo2/scripts/filename not under root..

mercurial

4
推荐指数
1
解决办法
627
查看次数

将值分配给空字符*

在以下代码中:

const char * my_func1(char const *str)
{
    const char *a = func(); // returns a char *, but I guess its ok to assign non-const to const
    if(a == NULL)
    {
        MY_String b = str;      //MY_String is an inhouse class with string functions
        b.replace("\"", "\'");  //replace " with '
        a = (const char *)b;    //MY_string has an operator (const char *)
    } 

    return a;
}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是,当anull,它进入if块,分配给a工作不正常,我也得到垃圾.是不是因为anull我不能赋值呢?我该如何解决?

c++

1
推荐指数
1
解决办法
215
查看次数

标签 统计

c++ ×1

javascript ×1

mercurial ×1