`
yianpuodiaotu
  • 浏览: 241686 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

js的startWith和endWith

 
阅读更多
<html>
	<head>
		<script>
		function doStartAll() {
			var allCheck = document.updateBusinessForm.getElementsByTagName("input");
			var checkList='';
			for(var i=0; i<allCheck.length; i++){
				var tagBody = allCheck[i];
					if(tagBody.getAttribute("name").startWith('name1')){
						checkList += tagBody.value  + '|';
					}
			}
			alert(checkList);
		}	
		
		String.prototype.startWith=function(str){
			if(str==null||str==""||this.length==0||str.length>this.length)
			  return false;
			if(this.substr(0,str.length)==str)
			  return true;
			else
			  return false;
			return true;
		}
		String.prototype.endWith=function(str){
			if(str==null||str==""||this.length==0||str.length>this.length)
			  return false;
			if(this.substring(this.length-str.length)==str)
			  return true;
			else
			  return false;
			return true;
		}

		</script>
	</head>
<body>
<form name="updateBusinessForm" method="get" action="businessUpdateStateEpaper.do">
	<input name="name1.a" value="a"/>
	<input name="name1.b" value="b"/>
	<input name="name1.c" value="c"/>
	<input name="name1.d" value="d"/>

	<input type="submit" class="button" id="" value="启用" onClick="doStartAll();"/>
</form>
</body>
</html>

 

分享到:
评论

相关推荐

    javascript中的startWith和endWith的几种实现方法

    JavaScript采用正则表达式实现startWith、endWith效果函数 代码如下:String.prototype.startWith=function(str){ var reg=new RegExp(“^”+str); return reg.test(this); } String.prototype.endWith=function...

    javascript自定义startWith()和endWith()的两种方法.docx

    ### JavaScript自定义startWith()和endWith()方法详解 #### 一、引言 在JavaScript中,`String.prototype.startsWith()` 和 `String.prototype.endsWith()` 方法分别用于判断字符串是否以指定的子串开头或结尾。这...

    javascript自定义startWith()和endWith()的两种方法

    一、采用正则表达式实现startWith、endWith效果函数 代码如下: String.prototype.startWith=function(str){ var reg=new RegExp(“^”+str); return reg.test(this);... } 二、JavaScript实现startWith、endWith效果

    Server Side development with Node.js and Koa.js

    We will dive into new concepts in JavaScript development, and see how paradigms such as async/await help with modern Node.js application development. By the end of this book, you will be building ...

    JS常用函数方法收集1

    startWith.js 判断是否以某个字符串开头 endWith.js 判断是否以某个字符串结束 HtmlEncode.js 转义html标签 dateFormat.js 时间日期格式转换 timeFormat.js 时间个性化输出功能 isDigit.js 判断是否为数字类型 ...

    《Jump Start Node.js》英文原版 Kindle - mobi格式

    With Jump Start Node.js, you’ll pick up the basics of Node.js, and learn to put it to work right away. Node.js is different because it allows you to write front- and back-end code: that means, all ...

    Single Page Web Applications JavaScript end-to-end

    You’ll learn the SPA design approach, and then start exploring new techniques like structured JavaScript and responsive design. And you’ll learn how to capitalize on trends like server-side ...

    Beginning Node.js

    You will see how using Node.js can be a fun and rewarding experience - start today with Beginning Node.js. What you’ll learn • Learn how JavaScript can help you be highly productive as a full-...

    JavaScript Domain-Driven Design(PACKT,2015)

    You'll start with learning domain-driven concepts and working with UML diagrams. You'll follow this up with how to set up your projects and utilize the TDD tools. Different objects and prototypes ...

    《Jump Start Node.js》- 2017 英文原版

    With Jump Start Node.js, you’ll pick up the basics of Node.js, and learn to put it to work right away. Node.js is different because it allows you to write front- and back-end code: that means, all ...

    VuePress Quick Start Guide

    What are static site generators, why do you need them, and how are they better than ...By the end of the book, you will have built your own static website by leveraging the power of Vue.js and VuePress.

    javascript常用方法

    - `startWith(s)`:检查字符串是否以指定的子字符串`s`开头。 - `endWith(s)`:检查字符串是否以指定的子字符串`s`结尾。 - `HtmlEncode(text)`:对字符串中的特殊字符进行转义,防止HTML注入。 2. 正则表达式:...

    Truffle quick start guide

    Also, you will dive into migration, testing and integrating Truffle with the use of popular JavaScript frameworks. Lastly, you will ship your decentralized application and package it into a product. ...

    源码+书Hands-on Data Structures and Algorithms with JavaScript

    Key FeaturesA step by step guide, which will provide you with a thorough discussion on the analysis and design of fundamental JavaScript data structuresGet a better understanding of advanced concepts ...

    D3.js in Action(Manning,2015)

    You'll start with in-depth explanations of D3's out-of-the-box layouts, along with dozens of practical use cases that align with different types of visualizations. Then, you'll explore practical ...

    Getting Started with hapi.js(PACKT,2016)

    By the end of this book, you’ll be equipped with all the skills you need to build your first fully featured application. This book will be invaluable if you are investigating Node.js frameworks or ...

    Javascript中字符串相关常用的使用方法总结

    - `substring(start, end)` 和 `slice(start, end)` 方法用于截取字符串的一部分。 ```javascript console.log(str.substring(1, 4)); // 输出ell console.log(str.substring(1)); // 输出ello,world console....

Global site tag (gtag.js) - Google Analytics