0

我使用 oracle apex 作为前端来设计屏幕并使用 java 脚本进行验证。

创建了一个名为选择列表的项目。When select list is null it must highlight the boarder with color. 以下是我用来为选择列表着色的功能,但这不起作用需要专家建议修复

<script>
function formvalidation()
{
     //Select List Item 
      var f1 = $x('P1_COUNTRY');
      if( f1.value == "" )
      {
         f1.style.borderColor = "red";
         f1.focus();
         return false;
      }
}   
</script>

onblur="formvalidation()";在事件上调用上述函数

4

1 回答 1

1

问题可能是您没有为边框设置宽度。你告诉它有一个红色边框,但没有任何宽度。您还可以从处理程序传递对 select 元素的引用。

onblur="formvalidation(this)";

// 'this' is the element receiving the blur event
function formvalidation(this)
{
      if( this.value == "" )
      {
         this.style.border = "1px solid red";
         this.focus();
         return false;
      }
}   
于 2013-01-08T05:59:44.643 回答