Description: JavaScript script, verify the data items in the form begin
-------------------------------- -----------------------------------------------
*/
function checkForm(objFrm){
var len = 0;
len = objFrm.elements.length;
var i = 0;
var objCheck;
//Text Box
for(i = 0; i objCheck = objFrm.elements[i];
if(objCheck.type == "text" && !f_checkTextValid(objCheck) ) {
return false;
}
}
//Drop-down box
for(i = 0; i objCheck = objFrm.elements [i];
if(objCheck.type == "select-one" && !f_checkSelectValid(objCheck) ){
return false;
}
}
///Time The segment is valid
if( f_checkStartAndEndDate(objFrm) == false) return false;
return true;
}
function f_checkSelectValid(obj){
//alert("check select");
if(obj.options.length alert("No data in the drop-down selection box!");
return false;
}
return true;
}
function f_checkStartAndEndDate(frm){
var len = frm.elements.length;
if(len == null && len == 0) return true;
var i=0;
var temp;
var objCheck;
var objStartDate;
var objEndDate;
//alert("start date period check");
try{
for(i=0 ; iobjCheck = frm.elements[i];
temp = objCheck.name;
if( temp.indexOf("startDate") >0 ||temp.indexOf ("beginDate")>0 )
objStartDate = objCheck;
if( temp.indexOf("endDate") > 0 )
objEndDate = objCheck;
}
//alert (objStartDate.value);
//alert(objEndDate.value);
if(objStartDate.value==null || objStartDate.value =="" || objStartDate.value ==null || objStartDate. value == ""){
return true;
}
return checkTwoDate(objStartDate.value, objEndDate.value);
//alert("end date period check");
}catch(E){}
return true;
}
function f_checkTextValid(obj){
//Cannot be null
if(obj.getAttribute("isNeed") != null ){
if(f_isNotNull(obj) == false) return false;
}
//Cannot exceed the length
if(obj.getAttribute("maxlength") != null){
if(f_checkLength(obj) == false) return false;
}
var checkType ="";
checkType = obj.getAttribute("checkType");
if(checkType==null ||checkType=="") return true;
//
if (checkType.indexOf("number") >=0){
if(f_isNumber(obj) == false) return false ;
if(f_checkNumType(obj,checkType) == false) return false;
}
//
if (checkType.indexOf("positive") >=0){
if(f_isNumber(obj) == false) return false;
if(f_isPositive(obj)==false) return false;
if(f_checkNumType(obj,checkType) == false) return false;
}
if (checkType.indexOf("date") >=0){
if(f_checkDate(obj) == false) return false;
}
/*
switch( checkType){
case "number": if(f_isNumber(obj) == false) return false;break;
case "date": if(f_checkDate(obj) == false) return false;break;
default:
}
*/
return true;
}
function f_isNotNull(obj){
if(obj.value == ""){
f_alert (obj, "Null values are not allowed! ");
return false;
}
return true;
}
function f_isNumber(obj){
if(isNaN(obj.value)){
f_alert( obj,"should be of numeric type");
return false;
}
return true;
}
function f_checkDate(obj) {
if(checkDate(obj .value) ==false){
f_alert(obj," is not a legal date format!");
return false;
}
return true;
}
function f_checkLength(obj){
if(getTotalBytes(obj) > Math.abs( obj.getAttribute("maxlength") ) ){
f_alert(obj," 超出长度限制!");
return false;
}
return true;
}
function f_alert(obj,alertStr){
var fielName = obj.getAttribute("fieldName");
if(fielName == null)
fielName = "";
alert(fielName "n" alertStr);
obj.select();
obj.focus();
}
function f_checkNumType(obj, numType){
//假设: 已经进行数字类型判断
var strTemp;
var numpric;
var numLen;
var strArr;
var defaultLen = 19;
var defaultpric = 5;
try{
if(numType == null|| numType =="") return f_checkNumLenPrec(obj,defaultLen, defaultpric);
if(numType.indexOf("(") strTemp = numType.substr( numType.indexOf("(") 1 ,numType.indexOf(")") - numType.indexOf("(") -1 );
if(strTemp == null||strTemp =="") return f_checkNumLenPrec(obj,defaultLen, defaultpric);
strArr = strTemp.split(",");
numLen = Math.abs( strArr[0] );
numpric = Math.abs( strArr[1] );
return f_checkNumLenPrec(obj,numLen, numpric);
}catch(e){
alert("in f_checkNumType = " e);
return f_checkNumLenPrec(obj,defaultLen, defaultpric);
}
}
function f_checkNumLenPrec(obj, len, pric){
var numReg;
var value = obj.value;
var strValueTemp, strInt, strDec;
//alert(value "=====" len "=====" pric);
try{
numReg =/[-]/;
strValueTemp = value.replace(numReg, "");
strValueTemp = strValueTemp.replace(numReg, "");
//整数
if(pric==0){
numReg =/[.]/;
//alert(numReg.test(value));
if(numReg.test(value) == true){
f_alert(obj, "输入必须为整数类型!");
return false;
}
}
if(strValueTemp.indexOf(".") //alert("lennth==" strValueTemp);
if(strValueTemp.length >( len - pric)){
f_alert(obj, "整数位不能超过" (len - pric) "位");
return false;
}
}else{
strInt = strValueTemp.substr( 0, strValueTemp.indexOf(".") );
//alert("lennth==" strInt);
if(strInt.length >( len - pric)){
f_alert(obj, "整数位不能超过" (len - pric) "位");
return false;
}
strDec = strValueTemp.substr( (strValueTemp.indexOf(".") 1), strValueTemp.length );
//alert("pric==" strDec);
if(strDec.length > pric){
f_alert(obj, "小数位不能超过" pric "位");
return false;
}
}
return true;
}catch(e){
alert("in f_checkNumLenPrec = " e);
return false;
}
}
function f_isPositive(obj){
var numReg =/[-]/;
if(numReg.test(obj.value) == true){
f_alert(obj, "必须为正数!");
return false;
}
return true;
}
/*
function selectedCheckboxCount(form)
Function description: Count the selected options in the Form
Parameter description:
form: the specified form
*/
function selectedCheckboxCount(form){
var length =0;
var i=0;
var count =0;
eles = form.elements;
while(i
//type = obj.attributes.item("type").nodeValue;
type = obj.type;
if(type == "checkbox"){
if(obj.checked){
count ;
}
}
i ;
}
return count;
}
//Get the byte length
function getByteLen(str)
{
var l = str.length;
var n = l;
for ( var i=0; iif ( str.charCodeAt(i) 255 )
n=n 1;
return n
}
/*
Instructions:
1. Clear the data (0.0 and 0) in the table
2. If there is no data in the cell, a space will be automatically added
3. Clear the checkbox of the blank row
Parameters:
clearzero: whether to clear "0", "0.0", false not to clear, true to clear (default is true)
tablename: name of the table to be cleared, default is sortTable
*/
function clear_table(clearzero,tablename)
{
var tobject;
if(tablename==null)
tobject=gmobj("sortTable");
else
tobject= gmobj(tablename);
//If table is not defined, no filtering will be performed
if(tobject==null)
return;
//If the function call parameter is empty, it means To clear 0, 0.0; conversely, do not clear 0, 0.0.
var clear = (clearzero==null)?true:clearzero;
//Clear 0, 0.0, fill in the spaces
var rows = tobject.rows;
var j=0;
for(var i=0;i
//Get the attribute clear of the first cell. If it is 1, it means there is no data in the row, then clear all the data in the row
while(tobject.rows[i].cells[j] != null)
{
if(clear)
{
if(tobject.rows[i].cells[j] .innerHTML==0 ||tobject.rows[i].cells[j].innerHTML==0.0||tobject.rows[i].cells[j].innerHTML=="")
tobject.rows[ i].cells[j].innerText=" ";
}
else
{
if (tobject.rows[i].cells[j].innerHTML=="")
tobject.rows[i].cells[j].innerText=" ";
}
j ;
}
j=0;
}
return true;
}
function gmobj(mtxt) /* Get object by object name */
{
if (document.getElementById) {
m=document.getElementById(mtxt);
} else if (document.all) {
m=document.all[mtxt];
} else if (document.layers) {
m=document.layers[mtxt];
}
return m;
}
/*
---------------------------------- -----------------------------------------------
Description: JavaScript Script, verify data items in the form end
----------------------------------------- ----------------------------------------
*/
/ *
Purpose: Check whether the input string is in a decimal number format, which can be a negative number (and meet the specified precision)
Input: str: string
l: total number of digits
d: Number of digits after the decimal point
Returns:
Returns true if the verification is passed, otherwise returns false
*/
function isDecimal( str,l,d){
if(isInteger(str)) {
if (l==null) return true;
if (strif (str.length}
var re = /^[-]{0,1}(d )[.] (d )$/;
if (re.test(str)) {
if (l==null) return true;
if (d==null) d=0;
if(RegExp.$1==0&&RegExp.$2==0) return false;
if (RegExp.$1.length RegExp.$2.length&& RegExp.$2.length}
return false;
}
onclick="isNull('Co.PageForm.CompetitorName');"
Co--refer to this page PageForm--refer to formName CompetitorName---refer to text column name

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

Matter.js is a 2D rigid body physics engine written in JavaScript. This library can help you easily simulate 2D physics in your browser. It provides many features, such as the ability to create rigid bodies and assign physical properties such as mass, area, or density. You can also simulate different types of collisions and forces, such as gravity friction. Matter.js supports all mainstream browsers. Additionally, it is suitable for mobile devices as it detects touches and is responsive. All of these features make it worth your time to learn how to use the engine, as this makes it easy to create a physics-based 2D game or simulation. In this tutorial, I will cover the basics of this library, including its installation and usage, and provide a

This article demonstrates how to automatically refresh a div's content every 5 seconds using jQuery and AJAX. The example fetches and displays the latest blog posts from an RSS feed, along with the last refresh timestamp. A loading image is optiona


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool