在powerschool中创建自定义页面

时间:2018-05-25 20:38:44

标签: javascript jquery html web

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

1 个答案:

答案 0 :(得分:0)

永远不会将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 = $也已修复。