js获取input处理
<!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=gb2312" />
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="address=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>无标题文档</title>
<style type="text/css">
body{margin: 0; padding: 0;}
#myform{ width: 200px; position: absolute; top:50%; left:50%; margin: -100px 0 0 -100px;}
#num{width: calc(100% - 8px); line-height: 2.0em;}
#btn{ width: 100%; margin: 20px 0 0 0; padding: 5px 0;}
#showValue{width: 100%; text-align: center; margin: 20px auto;}
</style>
</head>
<body>
<form id="myform" name="myform" method="post" action="">
<input type="text" name="num" id="num" value="202303020826" />
<input type="button" id="btn" name="button" value="获取" onclick="btns()" />
<div id="showValue"></div>
</form>
<script language="javascript">
function btns(){
var list={"00":"0","01":"9","02":"6","03":"5","04":"8","05":"1","06":"4","07":"5","08":"4","09":"5","10":"1","11":"8","12":"5","13":"3","14":"7","15":"5","16":"6","17":"5","18":"8","19":"3","20":"3","21":"9","22":"7","23":"4","24":"1","25":"7","26":"0","27":"4","28":"9","29":"4","30":"9","31":"8","32":"3","33":"4","34":"8","35":"7","36":"9","37":"3","38":"4","39":"8","40":"9","41":"6","42":"2","43":"2","44":"8","45":"3","46":"0","47":"2","48":"9","49":"8","50":"9","51":"9","52":"2","53":"2","54":"0","55":"1","56":"7","57":"8","58":"2","59":"7","60":"0","61":"5","62":"6","63":"4","64":"9","65":"6","66":"8","67":"3","68":"2","69":"4","70":"4","71":"7","72":"2","73":"9","74":"2","75":"5","76":"5","77":"5","78":"4","79":"5","80":"7","81":"2","82":"0","83":"5","84":"9","85":"8","86":"1","87":"6","88":"1","89":"5","90":"3","91":"2","92":"5","93":"0","94":"3","95":"4","96":"9","97":"6","98":"7","99":"4"}
var input=myform.num;
var inputValue=input.value;
var ivlength=inputValue.length;
var show=document.getElementById('showValue');
if(ivlength!=12){
show.innerHTML="格式不正确";
show.style.color="#f00";
}else if(isNaN(inputValue)){
show.innerHTML="格式必须为数字";
show.style.color="#f00";
}else{
var pw1=inputValue.slice(0,2)
var pw2=inputValue.slice(2,4)
var pw3=inputValue.slice(4,6)
var pw4=inputValue.slice(6,8)
var pw5=inputValue.slice(8,10)
var pw6=inputValue.slice(10,12)
show.innerHTML=list[pw1] + list[pw2] + list[pw3] + list[pw4] + list[pw5] + list[pw6];
//document.write(inputValue);
//alert(inputValue);
}
}
</script>
</body>
</html>
js获取input处理的更多相关文章
- js获取input上传文件名和后缀
var file = $("#filedata").val(); var pos = file.lastIndexOf("\\"); var filename ...
- 使用JS获取input值
获取input值,设置input值 可以使用 $(".class") $("#id") $("input[name='name']") re ...
- 有趣的js获取input标签中光标的索引
先看动图如下,我们就可以很清楚的知道获取input标签中光标的索引的意思了. 由于IE支持document.selection,Firefox,Chrome,Safari以及Opera都有select ...
- js 获取input type="file" 选择的文件大小、文件名称、上次修改时间、类型等信息
文件名的传递 ---全路径获取 $('#file').change(function(){ $('#em').text($('#file').val()); }); 文件名的传递 ---只获取文件名 ...
- js 获取input file路径改变图像地址
html代码 <img id="newImage" alt="100x100" src="__PUBLIC__/img/1.jpg" ...
- js获取input file路径改变图像地址
版权声明:好歹是我写的或者总结的或者抄的,总待给我个名份吧~ https://blog.csdn.net/sangjinchao/article/details/52250318 html代码 < ...
- js获取 input file 图片缩略图
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js 获取input选择的图片的信息
1JS $("#btn").click(function () { var imageEle = document.getElementById("images" ...
- js获取input checkbox的选中值
HTML代码: <form action="/test/action" method="get"> <input type="che ...
- js 获取 input file 文件 附给 image src
var a=document.querySelector('input[type=file]'); a.onchange = function (e) { //var reader = new Fil ...
随机推荐
- CPU 和 CPU Core 有啥区别?多核 CPU?多个 CPU?
CPU 全称 Central Processing Unit,中央处理器,计算机的大脑,长这个样子: CPU 通过一个插槽安装在主板上,这个插槽也叫做 CPU Socket,它长这个样子: 而我们说的 ...
- 互斥锁 线程理论 GIL全局解释器锁 死锁现象 信号量 event事件 进程池与线程池 协程实现并发
目录 互斥锁 multiprocessing Lock类 锁的种类 线程理论 进程和线程对比 开线程的两种方式(类似进程) 方式1 使用Thread()创建线程对象 方式2 重写Thread类run方 ...
- .Net执行SQL/存储过程之易用轻量工具
支持.Net/.Net Core/.Net Framework,可以部署在Docker, Windows, Linux, Mac. 由于该工具近来被广东省数个公司2B项目采用,且表现稳定,得到良好验证 ...
- Mybatis-plus实现数据库的增删改查操作
目录 1.MybatisPlus简介 2.MybatisPlus注解介绍 3.常用方法 4.SpringBoot整合MybatisPlus实现增删改查的一个简单Demo 5.参考资料 1.Mybati ...
- C#开发的磁吸屏幕类库 - 开源研究系列文章
上次写了一个关于线程池的博文,里面讲到了关于磁吸屏幕的类库,今天就把这个类库进行下讲解. 一. 类库目录: 类库的目录见下图,主要定义了Win32的一些API,以及一些API使用到的常量和结 ...
- 巧用Fiddler开启运营商定制版路由器被阉割的功能,免去刷公版固件的风险
前言: 三大运营商都有自己的定制版路由器,一般会在自家营销活动中作为赠品送给用户 正巧我家里就有两台电信定制版的华为路由器,都是这两年双十一在某宝上买宽带时送的 两台路由器型号分别是TC7001和TC ...
- python之路56 dajngo最后一天 csrf跨站请求 auth模块登录注册方法
csrf跨站请求伪造 钓鱼网站:模仿一个正规的网站 让用户在该网站上做操作 但是操作的结果会影响到用户正常的网站账户 但是其中有一些猫腻 eg:英语四六级考试需要网上先缴费 但是你会发现卡里的钱扣了但 ...
- 02-Sed语法介绍
1 Sed语法介绍 介绍Sed支持的基本命令及其命令行语法,Sed可以通过以下两种形式进行调用: 学习sed命令使用之前,需要掌握正则表达式的用法. sed [-n] [-e] 'commands' ...
- Ant Design Table 如何动态自定义?Ant Popover 遮挡?
项目场景: 基于electron + Vue + node.js + express + mysql + evanpatchouli-mysql + Ant-Design-Vue,编写一款属于自己的轻 ...
- 常用的SQL命令:
丢弃指定的数据库,如果存在的话 DROP DATABASE IF EXISTS xuezi; 创建新的数据库 CREATE DATABASE xuezi; 进入数据库xuezi USE xue ...