首页 > 解决方案 > 在 powerschool 中创建自定义页面

问题描述

我正在尝试在 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 -->

标签: javascriptjqueryhtmlweb

解决方案


jQuery 永远不会分配给$j. 您可以替换$j$或仅$j = $在脚本的开头添加。

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

您的脚本的问题是您正在调用一个不存在的 ID,$j("#submit")因为<button name="submit" type="button" disabled>Submit</button>没有 ID。此外,该show功能不会删除该disabled属性,您将需要使用prop('disabled', false).

这是一个脚本固定和固定的jsFiddle$j = $


推荐阅读