【问题标题】:creating custom page in powerschool在 powerschool 中创建自定义页面
【发布时间】:2019-11-12 10:39:57
【问题描述】:

我正在尝试在 powerschool(测试服务器)中创建自定义页面。我已经写了一些代码。实际上问题是脚本永远不会被触发。我在想脚本会被触发,因为密码文本框上有 keyup 事件。不确定我做得对。我是网页新手。有人可以帮忙吗?

<!DOCTYPE html>
<html>
<!-- start right frame -->
<head>
<title>Student Information</title>
</head>
<body>

<form  id="StudentInformationForm" action="/admin/changesrecorded.white.html" method="POST">

<!-- start of content and bounding box -->
<div class="box-round">

<table border="0" cellspacing="0" cellpadding="3" class="linkDescList">
<colgroup><col><col></colgroup>
<td colspan="2"> </td>
</tr>
<tr class="headerRow">
    <td colspan="2" class="bold">-Student Information</td>
</tr>

<tr class="Information">
    <td>
        <div>
            <label>Student Email Address</label>
            <input type="text" name="studentEmailAddress" />
        </div>
        <div>
            <label>Student Password</label>
            <input type="text" name="studentWebPassword" />
        </div>
        <div>
            <label>Grade</label>
            <label name="studentGrade">3<label/>
        </div>
        <div>
            <button name="submit" type="button" disabled>Submit</button>
        </div>
    </td>
</tr>
</table>
</div>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$j(function(){
$j("body").on("keyup","input[name='studentWebPassword']",function(){

var current_password = $j("input[name='studentWebPassword']").val();
var studentGrade = $j("input[name='studentGrade']").val();
var password_valid = true;
var hasNumber = /\d/;
var hasSpeacialCharacters=/^[a-zA-Z0-9- ]*$/;

if(studentGrade>=6) //for the students in Grade 3 to 6
{
//password should be of 5 characters and must contain a number
    if (current_password.length<5 && current_password>8 && !hasNumber.test(current_password))
    {
    password_valid=false;
    }

}

if (password_valid && current_password!='') {
$j("#submit").show();
} 
});
});
</script>
</body>
</html><!-- end right frame -->

【问题讨论】:

    标签: javascript jquery html web


    【解决方案1】:

    jQuery 永远不会分配给$j。 您可以将$j 替换为$,也可以在脚本开头添加$j = $

    这是一个jsFiddle,添加了$j = $的修复

    您的脚本的问题是您调用的 ID 不存在 $j("#submit"),因为 &lt;button name="submit" type="button" disabled&gt;Submit&lt;/button&gt; 没有 ID。此外,show 函数不会删除disabled 属性,您需要使用prop('disabled', false)

    这是一个固定脚本的jsFiddle,也固定了$j = $

    【讨论】:

      猜你喜欢
      • 2019-09-03
      • 1970-01-01
      • 2012-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      相关资源
      最近更新 更多