首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在powerschool中创建自定义页面

在powerschool中创建自定义页面
EN

Stack Overflow用户
提问于 2018-05-25 20:38:44
回答 1查看 395关注 0票数 1

我试图在powerschool (测试服务器)中创建一个自定义页面。我写了一段代码。实际上,问题是脚本永远不会被触发。我以为脚本会被触发,因为密码文本框上有keyup事件。不知道我做得对不对。我对网页很陌生。有人能帮忙吗?

代码语言:javascript
复制
<!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 -->
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-25 20:52:56

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 = $也是固定的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50536558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档