我正在进行客户端表单验证以检查密码是否匹配.但验证功能总是返回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) 有没有人知道如何在保留文件历史记录的同时跨文件移动文件
我在用 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..
在以下代码中:
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)
我遇到的问题是,当a是null,它进入if块,分配给a工作不正常,我也得到垃圾.是不是因为a是null我不能赋值呢?我该如何解决?