正则表达式在php,java,javascript中分别应用
在javascript中用法举例
var rule = /^\d+$/;
if(!rule.test(addform.rmb_price.value)) {
alert('rmb_price must be number');
addform.rmb_price.focus();
return false;
}
在php中用法举例
$aa = "/^\d+$/";
if(preg_match($aa, "111")) {
echo "found";
}
在java中用法举例
相关文档:
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 co ......
Javascript的继承可以通过call、apply、prototype实现。
1、call:在子类中,用父类.call(this,arg0,arg1...)可以继承父类。注意call的位置,尽量在子类的第一行(js按顺序执行,放在后面可能对子类的其他属性、方法有影响。比如子类和父类有相同名字的方法,后面的覆盖前面的)。
<html>
<head>
<t ......
Javascript的事件绑定主要有四种方法(一下在IE中运行正常,但不保证其他浏览器):
[注:onXXX为某一事件,fun为某一function,domId为某一DOM对象id,event类型见后边附录。]
1、在DOM中,直接用onXXX="fun();"进行绑定
2、在Javascript代码中用 DOM对象.onXXX=fun 进行绑定
3、用 DOM对象.attach ......
调用JavaScript文件
用作导航栏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ......