是否可以从元素中删除 maxlength 属性?我认为将其设置为 0 会起作用,但 FF4 似乎会阻止输入任何内容。http://jsfiddle.net/hMc4y/
我听说将其设置为确实-1会触发错误并且removeAttribute也不起作用。
SQLAlchemy 允许在声明列时指定长度String:
foo = Column(String(10))
Run Code Online (Sandbox Code Playgroud)
如 SQL 中所示:
foo VARCHAR(10)
Run Code Online (Sandbox Code Playgroud)
我知道某些 DBMS 在表中创建行时使用此长度值来分配内存。但有些 DBMS(如 SQLite)不关心它,仅为了与 SQL 标准兼容而接受此语法。但某些 DBMS(如 MySQL)要求指定它。
就我个人而言,我喜欢指定某些文本数据的最大长度,因为它有助于设计 UI,因为您知道显示它所需的区域。
此外,我认为这将使我的应用程序行为在不同的 DBMS 中更加一致。
因此,我想通过检查其长度与声明的长度(当声明长度时)来验证插入时 String/Unicode 列的值。
第一个解决方案是使用检查约束:
from sqlalchemy import CheckConstraint, Column, Integer, String, create_engine
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine("sqlite:///:memory:", echo=True)
Base = declarative_base(bind=engine)
Session = sessionmaker(bind=engine)
class Foo(Base):
__tablename__ = "Foo"
id = Column(Integer, primary_key=True)
bar = Column(String(10), CheckConstraint("LENGTH(bar) < 10"))
Base.metadata.create_all() …Run Code Online (Sandbox Code Playgroud) TextBox控件提供了一个MaxLength属性,该属性允许将可插入文本放入该TextBox的客户端限制为指定数量的字符.
我的问题:
有没有办法可以限制文本框的宽度等于MaxLength属性?在我的情况下,文本框控件放在表格单元格中,就像在此片段中一样:
<td class=TDSmallerBold style="width:90%">
<asp:textbox id="txtTitle" runat="server"
CausesValidation="true"
Text="Type a title here..be concise but descriptive. Include price."
ToolTip="Describe the item with a short pithy title (most important keywords first). Include the price. The title you provide here will be the primary text found by search engines that index Zipeee content."
MaxLength="60"
Width="100%">
</asp:textbox>
Run Code Online (Sandbox Code Playgroud)
(我知道我不应该使用HTML表来控制布局......另一个主题是肯定的)但是有没有办法将实际宽度限制为键入框中允许的最大字符数?
我知道电子邮件地址限制为254个字符,但有没有一个资源可以概述常见字段的建议最大长度,例如电话,城市等联系信息?
似乎我工作的每个项目都只是从他们提出的极限上开始.我希望找到一个针对特定国家的规范参考.
编辑 - 更新每条评论的电子邮件maxlength.
我有一个textarea,如果输入的字符达到最大长度,我想阻止输入.
我目前有一个文本框的Jquery脚本,用于计算输入的字符,并希望添加一些内容,一旦输入150个字符,将阻止textarea中的输入.
我已经尝试将max-length插件与我的脚本结合使用,但它们似乎不起作用.感谢帮助.
当前代码
(function($) {
$.fn.charCount = function(options){
// default configuration properties
var defaults = {
allowed: 150,
warning: 25,
css: 'counter',
counterElement: 'span',
cssWarning: 'warning',
cssExceeded: 'exceeded',
counterText: '',
container: undefined // New option, accepts a selector string
};
var options = $.extend(defaults, options);
function calculate(obj,$cont) {
// $cont is the container, now passed in instead.
var count = $(obj).val().length;
var available = options.allowed - count;
if(available <= options.warning && available >= 0){
$cont.addClass(options.cssWarning);
} else {
$cont.removeClass(options.cssWarning); …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个包含长参数字符串(> MAX_PATH)的快捷方式(在桌面上).
在MSDN文档中明确指出,对Unicode字符串的字符串可以超过MAX_PATH.
生成的快捷方式在MAX_PATH字符(即Path+ Arguments)后完全切断.
我的实现是否有问题,或者这是一些Windows限制?
procedure CreateShortcut(APath: WideString;
AWorkingDirectory: WideString; AArguments: WideString; ADescription: WideString;
ALinkFileName: WideString);
var
IObject : IUnknown;
ISLink : IShellLinkW;
IPFile : IPersistFile;
begin
IObject := CreateComObject(CLSID_ShellLink);
ISLink := IObject as IShellLinkW;
ISLink.SetPath( PWideChar(APath));
ISLink.SetWorkingDirectory(PWideChar(AWorkingDirectory));
ISLink.SetArguments( PWideChar(AArguments));
ISLink.SetDescription( PWideChar(ADescription));
IPFile := IObject as IPersistFile;
IPFile.Save(PWideChar(ALinkFileName), False);
end;
Run Code Online (Sandbox Code Playgroud)
PS:操作系统是Windows XP(及以上版本).
我的架构源如下所示:
<xsd:schema xmlns="uuid:b8fd4596-56ec-4718-ad00-bf2a70a148c2" xmlns:tcmi="http://www.tridion.com/ContentManager/5.0/Instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="uuid:b8fd4596-56ec-4718-ad00-bf2a70a148c2">
<xsd:import namespace="http://www.tridion.com/ContentManager/5.0/Instance"></xsd:import>
<xsd:annotation>
<xsd:appinfo>
<tcm:Labels xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
<tcm:Label ElementName="description" Metadata="false">Description</tcm:Label>
<tcm:Label ElementName="multiline" Metadata="false">Multiline</tcm:Label>
</tcm:Labels>
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="Blog">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="description" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:appinfo>
<tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:normalizedString">
<xsd:minLength value="1"></xsd:minLength>
<xsd:maxLength value="20"></xsd:maxLength>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="multiline" minOccurs="0" maxOccurs="1" type="tcmi:MultiLineText">
<xsd:annotation>
<xsd:appinfo>
<tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
<configuration xmlns="http://www.sdltridion.com/2011/SiteEdit">
<field>
<editable>true</editable>
</field>
</configuration>
</tcm:ExtensionXml>
<tcm:Size xmlns:tcm="http://www.tridion.com/ContentManager/5.0">5</tcm:Size>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element></xsd:schema>
Run Code Online (Sandbox Code Playgroud)
我能够对"xsd:normalizedString"类型字段使用maxlength和minLength限制,但是我无法对"tcmi:MultiLineText"类型使用相同的限制.任何人都知道如何在这种类型的领域使用它们?
如果在该字段中无法使用该限制,我知道还有其他方法可以在Tridion中验证保存内容(正如Nuno和Robert在http://nunolinhares.blogspot.com.es/2012/07/validating中所解释的那样)-content-on-save-part-1-of.html和 …
从互联网研究来看,最大长度属性不适用于IE 8和9
为了解决这个问题我从这里尝试了一个解决方案,它使用了另一个用于表示textarea的函数:
//Dynamic append the textarea row
function do_resize(textArea) {
while (
textArea.rows > 1 &&
textArea.scrollHeight < textArea.offsetHeight
)
{
textArea.rows--;
}
while (textArea.scrollHeight > textArea.offsetHeight)
{
textArea.rows++;
}
textArea.rows++
}
<textarea name="q<%=countNo%>_ans" rows="3" cols="55" maxlength="2000" style="resize: none;" onkeyup="new do_resize(this);" onKeyPress="return ( this.value.length < 2000);"></textarea>
Run Code Online (Sandbox Code Playgroud)
问题是,textarea在IE8 9中超过2000之后无法输入任何字符,但我仍然可以使用超过textarea限制的复制和粘贴功能.如何解决这个问题?谢谢
标题几乎说明了一切...
我正在尝试强制在表单上输入文本的最大长度。字段之一可以是任何有效的浮点数。最大长度是多少?
例如,对于整数
// negative sign makes MIN_VALUE larger than MAX_VALUE
String.valueOf(Integer.MIN_VALUE).length();
Run Code Online (Sandbox Code Playgroud)
更新
我已经测试了以下内容:
String.valueOf(-Float.MIN_VALUE).length();
String.valueOf(-Float.MAX_VALUE).length();
String.valueOf( Float.MIN_VALUE).length();
String.valueOf( Float.MAX_VALUE).length();
Run Code Online (Sandbox Code Playgroud)
这给了我以下输出:
8
13
7
12
Run Code Online (Sandbox Code Playgroud)
我不认为最大长度是13
maxlength ×10
html ×3
javascript ×3
validation ×3
asp.net ×2
jquery ×2
textbox ×2
c# ×1
delphi ×1
delphi-2007 ×1
html-table ×1
java ×1
python ×1
shortcut ×1
sqlalchemy ×1
textarea ×1
tridion ×1
tridion-2011 ×1
width ×1
windows ×1