错误状态样式的jQuery交互提示

时间:2012-02-14 07:12:54

标签: jquery asp.net .net jquery-ui

我正在尝试使用jQuery CSS Framework来设置必需的字段错误。如果在文本框中提交的表单没有任何值,则应该阻止表单提交,并应显示与以下内容对应的样式。

•ui-helper-reset

•ui-helper-clearfix

•ui-state-error-text

•ui-icon-alert

这样做的最佳方式是什么?

注意:代码对应于ASP.NET(form runat="server"

代码:

<html lang="en">

<head>

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/themes/flick/jquery-ui.css"
    rel="stylesheet" type="text/css" />
<title>Interaction cues</title>
</head>

<body>
    <%-- ui-helper-reset, ui-helper-clearfix, ui-state-error-text,  ui-icon-alert--%>
    <form runat="server" >

        <div> 
            <a> User Name </a>
            <input id="Text1" type="text" />
            <span> * </span>
            <a>Required field</a> 
        </div>

    <input id="Button1" type="button" value="button" />
    </form>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

  • 在按钮上添加事件onclick
  • 在onclick函数上放置了你想要的所有验证
  • 如果成功__doPostBack('','');
  • 如果显示消息或其他内容失败