将msgbox输入大小限制为20

时间:2014-03-27 08:49:03

标签: jquery asp.net-mvc-4 msgbox

$.msgbox("Editar Contato", {
                type: "prompt",
                inputs: [
                  { type: "text", id: "txtname", label: "Nome:", value: nome, required: true,maxlength: "20" },
                  { type: "email", id: "txtemail", label: "Email:", value: email, required: true,maxlength: "20" },
                  { type: "text", id: "txttelipho1", label: "Telefone 1:", value: teliphone1, required: true, maxlength: "20" },
                  { type: "text", id: "txttelipho2", label: "Telefone 2:", value: teliphone2, required: true, maxlength: "20" }
                ],
                buttons: [
                  { type: "submit", value: "Salvar" },
                  { type: "cancel", value: "Cancelar" }
                ]

上面的代码显示我输入的msgbox,数据库中的输入字段占用有限的字符为20然后如何停止用户不要在msgbox的输入字段中输入超过20个字符

我使用了maxlength但是不能阻止在输入中输入超过20个租船人

谢谢........

1 个答案:

答案 0 :(得分:0)

你可以使用maxlength属性将maxlength属性设置为textbox。这样的东西:

 { type: "text",
 id: "txtname",
 label: "Nome:",
 value: nome,
 required: true,
 maxlength:"20" },

对于msgbox:

$.msgbox("Editar Contato", {

type: "prompt",
inputs: [
  { type: "text", id: "txtname", label: "Nome:", value: nome, required: true,maxlength:"20" },
  { type: "email", id: "txtemail", label: "Email:", value: email, required: true },
  { type: "text", id: "txttelipho1", label: "Telefone 1:", value: teliphone1, required: true,maxlength:"20" },
  { type: "text", id: "txttelipho2", label: "Telefone 2:", value: teliphone2, required: true,maxlength:"20" }
],
buttons: [
  { type: "submit", value: "Salvar" },
  { type: "cancel", value: "Cancelar" }
]