JavaScript格式化字符串工具
Several programming languages implement a sprintf function, to output a formatted string. It originated from the C programming language, printf function. Its a string manipulation function.
This is limited sprintf Javascript implementation. Function returns a string formatted by the usual printf conventions. See below for more details. You must specify the string and how to format the variables in it. Possible format values:
%% – Returns a percent sign
%b – Binary number
%c – The character according to the ASCII value
%d – Signed decimal number
%f – Floating-point number
%o – Octal number
%s – String
%x – Hexadecimal number (lowercase letters)
%X – Hexadecimal number (uppercase letters)
Additional format values. These are placed between the % and the letter (example %.2f):
+ (Forces both + and – in front of numbers. By default, only negative numbers are marked)
– (Left-justifies the variable value)
0 zero will be used for padding the results to the right string size
[0-9] (Specifies the minimum width held of to the variable value)
.[0-9] (Specifies the number of decimal digits or maximum string length)
If you plan using UTF-8 encoding in your project don’t forget to set the page encoding to UTF-8 (Content-Type meta tag), and use Javascript UTF-8 utility found on this website.
原文链接: http://www.webtoolkit.info/javascript-sprintf.html
下载:
webtoolkit.sprintf.js
http://download.csdn.net/source/1972105
相关文档:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JS调用现成Word模板完成打印</title>
<script type="text/javascript">
//转换word的函数
function ......
我们常常在编写Java程序时会用到Properties文件,把一些Message等信息放在Properties文件,但是我们看到的都是一些编码。
Struts1.1b2的例子中的本国资源文件经过Unicode编码的,所以你如果要和它的运行一样,也必须将你的ApplicationResources_zh进行Unicode编码。有以下两种方法:
①使用jdk的native2ascii工具。 ......
*说明:select元素javascript常用操作
* 1.判断是否存在指定value的Item
* 2.加入一个Item
* 3.删除值为value的所有Item
* 4.删除某一个index的选项
* 5.更新第index项的value和text
* 6.设置select中指定text的第一个Item为选中
* 7.设置select中指定value的第一个Item为选中
* 8.得到当前选中项的v ......
引言
增加客户端的表单验证可以为用户提供更快的体验,但决不能忽视的是,客户端表单验证永远不应该取代服务器端的验证,而只能是辅助和增强。根据经验JavaScript验证表单基本分为以下几方面的内容,必填字段、特殊模式匹配等,还要注意错误的提示方式对一个表单的可用性有着极其重要的影响。
2建立表单
&nb ......