Okay, so I'm building a custom signup page, and of course there is javascript input validation involved.
好的,所以我正在建立一个自定义注册页面,当然还有javascript输入验证。
In that validation I'm using the maxlength
property, to validate the length of the input - it's kind of a double security, but it was so easy to get the property of the element I thought "why not?".
在那个验证中我使用了maxlength属性来验证输入的长度 - 这是一种双重安全性,但是很容易获得我认为“为什么不呢?”这个元素的属性。
However, I discovered that the attribute was undefined
on some of my form input elements, and correctly defined on others.
但是,我发现在我的一些表单输入元素上未定义该属性,并在其他元素上正确定义。
I've been looking at the HTML for several days now, and I can't figure out why it is not defined on some of the elements, but works on most.
我已经看了几天HTML了,我无法弄清楚为什么它没有在某些元素上定义,但最常用。
I've constructed a page where both the working and non-working elements exist, although it is not how it is supposed to be put together in the end.
我已经构建了一个页面,其中存在工作元素和非工作元素,尽管它最终不应该如何组合在一起。
Here is a link to that, and below is an example of the non-working form. I hope some of you guys can see what's wrong with it!
这是一个链接,下面是非工作表单的示例。我希望你们中的一些人能看出它有什么问题!
Code:
<div id="9irBGsdLR">
<form method="POST" class="form" name="frontContent" id="forntContent" style="margin-bottom:15px;">
<div id="9button" style="float:right;">
<img onclick="deleteElement('9', '9irBGsdLR', this, 'actions/delete.php')" alt="delete" style="border:0px;float:right;cursor:pointer;" src="./validationNotWorking_files/close_32.png">
</div>
<input type="text" name="id" style="display:none;" value="9">
<label class="inputlabel softInputlabel" style="width:20%;">Headline: </label>
<input maxlenght="50" type="text" name="title" id="title" class="inputfield" contenttype="text" value="Praesent rhoncus faucibus elementum">
<label class="inputlabel softInputlabel" style="width:20%;">Succession: </label>
<input maxlenght="4" type="text" name="succession" id="title" class="inputfield" contenttype="numerical" value="50">
<label class="inputlabel softInputlabel" style="width:20%;">Content: </label>
<textarea class="formField" style="width:75%;height:300px;" name="content"></textarea>
</form>
<hr>
</div>
1 个解决方案
#1
3
There is no such thing as maxlenght
- use maxlength
instead.
没有maxlenght这样的东西 - 使用maxlength代替。
Here's a jsFiddle.
这是一个jsFiddle。
HTML:
<div id="9irBGsdLR">
<form method="POST" class="form" name="frontContent" id="forntContent" style="margin-bottom:15px;">
<div id="9button" style="float:right;">
<img onclick="deleteElement('9', '9irBGsdLR', this, 'actions/delete.php')" alt="delete" style="border:0px;float:right;cursor:pointer;" src="./validationNotWorking_files/close_32.png">
</div>
<input type="text" name="id" style="display:none;" value="9">
<label class="inputlabel softInputlabel" style="width:20%;">Headline: </label>
<input maxlength="50" type="text" name="title" id="title" class="inputfield" contenttype="text" value="Praesent rhoncus faucibus elementum">
<label class="inputlabel softInputlabel" style="width:20%;">Succession: </label>
<input maxlength="4" type="text" name="succession" id="title" class="inputfield" contenttype="numerical" value="50">
<label class="inputlabel softInputlabel" style="width:20%;">Content: </label>
<textarea class="formField" style="width:75%;height:300px;" name="content"></textarea>
</form>
<hr>
</div>
#1
3
There is no such thing as maxlenght
- use maxlength
instead.
没有maxlenght这样的东西 - 使用maxlength代替。
Here's a jsFiddle.
这是一个jsFiddle。
HTML:
<div id="9irBGsdLR">
<form method="POST" class="form" name="frontContent" id="forntContent" style="margin-bottom:15px;">
<div id="9button" style="float:right;">
<img onclick="deleteElement('9', '9irBGsdLR', this, 'actions/delete.php')" alt="delete" style="border:0px;float:right;cursor:pointer;" src="./validationNotWorking_files/close_32.png">
</div>
<input type="text" name="id" style="display:none;" value="9">
<label class="inputlabel softInputlabel" style="width:20%;">Headline: </label>
<input maxlength="50" type="text" name="title" id="title" class="inputfield" contenttype="text" value="Praesent rhoncus faucibus elementum">
<label class="inputlabel softInputlabel" style="width:20%;">Succession: </label>
<input maxlength="4" type="text" name="succession" id="title" class="inputfield" contenttype="numerical" value="50">
<label class="inputlabel softInputlabel" style="width:20%;">Content: </label>
<textarea class="formField" style="width:75%;height:300px;" name="content"></textarea>
</form>
<hr>
</div>