当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Js 控制表单域代码

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 Js 控制表单域代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 402 ::
收藏到网摘: n/a

js改变下拉框的显示等实现代码。
点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]

js验证为正整数
复制代码 代码如下:

<script>
var re = /^[1-9]d*$/; //智能验证单个字符
if (!re.test(document.getElementById('group_order').value)){
alert("组排序必须为数字!");
document.getElementById('group_order').focus();
return false;
}
</script>
if(value <0 || value!=parseInt(value) ){
alert("不是正整数");
}else{
alert("是正整数");
}

js发送表单(方法一): check_input 是js函数,但是这个方法会把页面内所有的表单都发送掉
复制代码 代码如下:

<% form_tag( {:controller=>"transaction",:action=>"check_cid"},{:name=>"form1",:method=>"post",:multipart=>"true" ,:onsubmit=>”return check_input();”}) do %>
<% end %>

js发送表单(方法二): check_original 是js函数,这个方法会发送指定的form,无论方法一,方法二 都别忘了 前面加 return
复制代码 代码如下:

<%= form_tag({:controller=>"program",:action=>"index"},{:name=>"newform",:method=>"post",:multipart=>"true"}) %>
<%= submit_tag "添加",{:name=>'newgroup',:onclick=>'return check_original();'} %>
<%= form_tag %>

待续................