非常讨厌在网页写文章, 写了半又没了, 又得重头来. 发下牢骚, 接着来!
实现功能:
1. Tooltip
2. Validate 表单验证
可分开独立使用
您可以不写一行代码, 只需设置验证规则即可
其实园子已经存在不少基于jQuery的验证插件, 如: http://www.cnblogs.com/wzmaodong/archive/2008/05/21/1203962.html
但感觉使用起来过于麻烦, 要实现在大堆表单的验证, javascript 代码一大堆. 所以这里的设计原则就是使用便捷, 易维护, 同时适应性大.
在验证中使用了自定义正则表达式, 这样用起来就非常方便了. 先看下最后的效果图
1. 即时表单验证和提示
2. 提交表单时验证
下面看下我们如何在 asp.net 中实现便捷的提示功能和表单验证功能

Code
<li>
<label>航班号</label>
<asp:TextBox ID="_flightno" runat="server" reg="\w{2}\d{4}" tip="设置航班号(大写)" toupper="true" />
</li>
<li>
<label>航司(2字代码)</label>
<asp:TextBox ID="_airline" runat="server" reg="\w{2}" toupper="true" /> (注意大写)
</li>
<li>
<label>起飞时间</label>
<asp:TextBox ID="_beingtime" runat="server" reg="\d{4}" tip="设置起飞时间 格式: hhmm" /> (格式: hhmm)
</li>
以上的实现是不是很方便, 不用写大堆的 javascript 逻辑代码便可轻松实现验证和提示功能
通过调用 $(document).ready(function() {jQuery('input[tip],input[reg]').tooltip({onsubmit: true})}); 便完成数据的验证和提示功能. (该调用已集成在tooltip.js中)
onsubmit: true 这里设置是否触发 onsubmit 的提交验证事件.
再看看 CSS 的实现
.tooltipinputerr

{
}{
padding: 2px 0 2px 18px;
border: solid 1px red;
background: #ffff99 url(/images/exclamation.png) no-repeat 2px center;
}
.tooltipinputok

{
}{
padding: 2px 0 2px 18px;
border: solid 1px green;
background: url(/images/accept.png) no-repeat 2px center;
}
.tooltipshowpanel

{
}{
z-index: auto;
display: none;
position:absolute;
width: 276px;
height: 35px;
overflow: hidden;
text-indent: 5px;
line-height: 40px;
font-size: 12px;
font-family: Arial;
background: url(/images/tooltop.gif) no-repeat left top;
opacity:0.9;
filter: alpha(opacity=90);
}
使用方法:
一.
Download jQuery
Download jQuery 1.2.6 (16kb, Minified and Gzipped) Great for production use.
Download jQuery 1.2.6 (97kb, Uncompressed) Great for testing, learning and development.
Download jQuery 1.2.6 (30kb, Packed) For those that can't Gzip their JavaScript.
二. 加入以上样式和引用tooltip.js文件
完整Demo下载 jquery-tooltip.rar
支持 Select Demo jquery-tooltip_select.rar
版本更新下载: TooltipAndRegex.rar
http://lab.berkerpeksag.com/jGrow
What is jGrow?
jGrow is a jQuery plug-in that makes the textarea adjust its size according to the length of the text.
It works smoothly with jQuery 1.2.x. It was tested on IE6/7, Firefox 2.0.x and Opera 9.x, and no bug was spotted yet.
非常好一个jQuery插件, 但原版不支持 Ctrl + V 的键盘操作事件, 直接代码.
/* 原版代码.
* jGrow 0.2
* 08.02.2008
* 0.2 release: 04.03.2008
*/
(function($) {
$.fn.jGrow = function(options) {
var opts = $.extend({}, $.fn.jGrow.defaults, options);
return this.each(function() {
$(this).css({ overflow: "hidden" }).bind("keypress", function() {
$this = $(this);
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
if(o.rows == 0 && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if((this.rows <= o.rows) && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if(o.rows != 0 && this.rows > o.rows) {
$this.css({ overflow: "auto" });
}
$this.html();
});
});
}
$.fn.jGrow.defaults = { rows: 0 };
})(jQuery);
以下为改进后的代码, 支持 Ctrl+V 键盘事件操作
/*
* jGrow 0.2
* 08.02.2008
* 0.2 release: 04.03.2008
*/
// Updated by S.Sams 2008-07-24 21:47 以兼容Ctrl+V的操作
(function($) {
$.fn.jGrow = function(options) {
var opts = $.extend({}, $.fn.jGrow.defaults, options);
return this.each(function() {
var isCtrl = false;
$(this).css({ overflow: "hidden" }).bind("keypress", function() {
$this = $(this);
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
if(o.rows == 0 && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if((this.rows <= o.rows) && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if(o.rows != 0 && this.rows > o.rows) {
$this.css({ overflow: "auto" });
}
$this.html();
}).bind("keydown",function(event){
if(event.keyCode == 17) isCtrl = true;
}).bind("keyup",function(event){
if(isCtrl && event.keyCode == 86)
{
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
var getCL = this.value.split('\n').length
if( getCL <= o.rows)
{
this.rows = getCL;
}
else
{
this.rows = o.rows;
$(this).css({ overflow: "auto" });
}
isCtrl = false;
}
});
});
}
$.fn.jGrow.defaults = { rows: 0 };
})(jQuery);
// 自适应 textarea 有内容存在的高度自动调整
/*
* jGrow 0.2
* 08.02.2008
* 0.2 release: 04.03.2008
*/
// Updated by S.Sams 2008-07-24 21:47 以兼容Ctrl+V的操作
(function($) {
$.fn.jGrow = function(options) {
var opts = $.extend({}, $.fn.jGrow.defaults, options);
return this.each(function() {
var isCtrl = false;
$(this).css({ overflow: "hidden" }).bind("keypress", function() {
$this = $(this);
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
if(o.rows == 0 && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if((this.rows <= o.rows) && (this.scrollHeight > this.clientHeight)) {
this.rows += 1;
} else if(o.rows != 0 && this.rows > o.rows) {
$this.css({ overflow: "auto" });
}
$this.html();
}).bind("keydown",function(event){
if(event.keyCode == 17) isCtrl = true;
}).bind("keyup",function(event){
if(isCtrl && event.keyCode == 86)
{
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
var getCL = this.value.split('\n').length
if( getCL <= o.rows)
{
if(getCL > parseInt(this.rows))
this.rows = getCL;
}
else
{
this.rows = o.rows;
$(this).css({ overflow: "auto" });
}
isCtrl = false;
}
});
// Updated by S.Sams 2008-07-25
// 修正 testarea 有内容存在的情况下的自动调整高度
if($(this).val().length > 0)
{
var o = $.meta ? $.extend({}, opts, $(this).data()) : opts;
var getCL = this.value.split('\n').length
if( getCL <= o.rows)
{
if(getCL > parseInt(this.rows))
this.rows = getCL;
}
else
{
this.rows = o.rows;
$(this).css({ overflow: "auto" });
}
}
});
}
$.fn.jGrow.defaults = { rows: 0 };
})(jQuery);
http://mediacdn.hongkongdisneyland.com.cn/html/hkdlch_v0101/staticPages/iasw/China/video/mv.flv
It's a world of laughter
A world of tears
It's a world of hopes
And a world of fears
There's so much that we share
That it's time we're aware
It's a small world after all
There is just one moon
And one golden sun
And a smile means
Friendship to ev'ryone
Though the mountains divide
And the oceans are wide
It's a small world after all
It's a small world after all
It's a small world after all
It's a small world after all
It's a sm
小小世界(普通话)
这是欢乐美丽的小世界
这是甜美幸福的小世界
啊 我们来跳舞
我们歌唱 歌唱美丽的小世界
这是一个小小世界
这是一个小小世界
这是一个小小世界
这是小世界
这是欢乐美丽的小世界
这是甜美幸福的小世界
啊 我们来跳舞
我们歌唱 歌唱美丽的小世界
这是一个小小世界
这是一个小小世界
这是一个小小世界
这是小世界
Earlier before I have written an article about current best CSS hacks which you can see here And now here’s the list of today’s most used CSS tricks – tips. I have added image examples for most of them because of critics on CSS hacks article. If you think I have missed any please let me know
1. Rounded corners without images
<div id=”container”>
<b class=”rtop”>
<b class=”r1″></b> <b class=”r2″></b> <b class=”r3″></b> <b class=”r4″></b>
</b>
<!–content goes here –>
<b class=”rbottom”>
<b class=”r4″></b> <b class=”r3″></b> <b class=”r2″></b> <b class=”r1″></b>
</b>
</div>
.rtop, .rbottom{display:block}
.rtop *, .rbottom *{display: block; height: 1px; overflow: hidden}
.r1{margin: 0 5px}
.r2{margin: 0 3px}
.r3{margin: 0 2px}
.r4{margin: 0 1px; height: 2px}

2. Style your order list
<ol>
<li>
<p>This is line one</p>
</li>
<li>
<p>Here is line two</p>
</li>
<li>
<p>And last line</p>
</li>
</ol>
ol {
font: italic 1em Georgia, Times, serif;
color: #999999;
}
ol p {
font: normal .8em Arial, Helvetica, sans-serif;
color: #000000;
}

3. Tableless forms
<form>
<label for=”name”>Name</label>
<input id=”name” name=”name”><br>
<label for=”address”>Address</label>
<input id=”address” name=”address”><br>
<label for=”city”>City</label>
<input id=”city” name=”city”><br>
</form>
label,input {
display: block;
width: 150px;
float: left;
margin-bottom: 10px;
}
label {
text-align: right;
width: 75px;
padding-right: 20px;
}
br {
clear: left;
}

4. Double blockquote
blockquote:first-letter {
background: url(images/open-quote.gif) no-repeat left top;
padding-left: 18px;
font: italic 1.4em Georgia, “Times New Roman”, Times, serif;
}

5. Gradient text effect
<h1><span></span>CSS Gradient Text</h1>
h1 {
font: bold 330%/100% “Lucida Grande”;
position: relative;
color: #464646;
}
h1 span {
background: url(gradient.png) repeat-x;
position: absolute;
display: block;
width: 100%;
height: 31px;
}
<!–[if lt IE 7]>
<style>
h1 span {
background: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’gradient.png’, sizingMethod=’scale’);
}
</style>
<![endif]–>

6. Vertical centering with line-height
div{
height:100px;
}
div *{
margin:0;
}
div p{
line-height:100px;
}
<p>Content here</p>

7. Rounded corners with images
<div class=”roundcont”>
<div class=”roundtop”>
<img src=”tl.gif” alt=”"
width=”15″ height=”15″ class=”corner”
style=”display: none” />
</div>
CONTENT
<div class=”roundbottom”>
<img src=”bl.gif” alt=”"
width=”15″ height=”15″ class=”corner”
style=”display: none” />
</div>
</div>
.roundcont {
width: 250px;
background-color: #f90;
color: #fff;
}
.roundcont p {
margin: 0 10px;
}
.roundtop {
background: url(tr.gif) no-repeat top right;
}
.roundbottom {
background: url(br.gif) no-repeat top right;
}
img.corner {
width: 15px;
height: 15px;
border: none;
display: block !important;
}

8. Multiple class name
<img src=”image.gif” class=”class1 class2″ alt=”" />
.class1 { border:2px solid #666; }
.class2 {
padding:2px;
background:#ff0;
}
9. Center horizontally
<div id=”container”></div>
#container {
margin:0px auto;
}

10. CSS Drop Caps
<p class=”introduction”> This paragraph has the class “introduction”. If your browser supports the pseudo-class “first-letter”, the first letter will be a drop-cap. </p>
p.introduction:first-letter {
font-size : 300%;
font-weight : bold;
float : left;
width : 1em;
}

11. Prevent line breaks in links, oversized content to brake
a{
white-space:nowrap;
}
#main{
overflow:hidden;
}
12. Show firefox scrollbar, remove textarea scrollbar in IE
html{
overflow:-moz-scrollbars-vertical;
}
textarea{
overflow:auto;
}