js中with(field)和with(thisform)

来源:互联网 发布:gotomeeting软件 编辑:程序博客网 时间:2024/06/15 15:37
function validate_required(field,alerttxt){with (field) // 判断 field 对象是否存在  {  if (value==null||value=="") // 判断field 是否为空,  {      //  field 为空,打印出提示文本alerttxt      alert(alerttxt);      return false // 返回false,表示验证失败  }  else {    //  field 不为空,表示验证成功    return true  }  }}with (thisform) // 判断 thisform 对象是否存在  {  // thisform 存在  // 存在,调用validate_required方法,验证email对象,验证失败打印"Email must be filled out!"  if (validate_required(email,"Email must be filled out!")==false)    {email.focus();return false}