The following usage needs to be added to the JSP in the attribute onclick. For example, onclick= "Javascript:allselect ()"//javascript can omit
or use the function Allselect () with document.getElementById ("Allselectbox"). onclick = function ();
Select All
Fuction Allselect () {
var form = document.forms[0];
var state = form.allselectbox.checked;
var length = Form.username.length;
if (length) {
for (Var i=0;i<length;i++) {
Form.usernames[i].checked=state;
}
}else Form.username.check = State;
}
Another way to do it all:
function Allselect () {
var items = document.getelementsbyname ("usernames");
var state = Document.getelementsbyname ("Allselectbox") [0].checked;
if (items.length) {
for (var i = 0; i < items.length; i++) {
items[i].checked = State;
}
}else{
items.checked = State;
}
}
Single selection:
Fuction SelectItem () {
var form = document.forms[0];
var length = Form.username.length;
if (length) {
for (Var i=0;i<length;i++) {
if (form.usernames[i].checked) return true;
}
}else return form.usernames.check;
}
Go to another page:
function ToPage (page) {
var form = Document.forms[0]
Form.page.value = page;
Form.submit;
}
To radio the value of a radio box:
function Getradiovalue (objradio) {
var result = "";
try{
if (typeof (objradio.value) = = "undefined") {
for (Var i=0;i<objradio.length;i++) {
if (objradio[i].checked) {
return objradio[i].value;
}
}
}else{
if (objradio.checked) result = Objradio.value;
}
}catch (e) {result = "";}
return result;
}
Email Verification:
function IsValidEmail (inemail) {
var filter =/^ ([a-za-z0-9_\.\-]) +\@ ([a-za-z0-9\-]) +\.) + ([a-za-z0-9]{2,4}) +$/;
Return Filter.test (Inemail);
}
Check phone format:
function Validatemobile () {
var form = document.forms[0];
if (form.mobile.value!= "") {
var num =/^1[35]\d{9}$/
if (!num.test (Form.mobile.value)) {
Alert ("The consignee's cell phone number is not in the correct format");
return false;
}
Alert ("correct");
}
}
Cond........
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service