JS Get text Box value

Source: Internet
Author: User

First, Get text box/edit box/hide Field box

<script type= "Text/javascript" >
functionMyCheck (){
var checkstr= "Get content as follows: \ n";
if (document.Form1. Article author. Value! = "") {
checkstr+= "author name:" +document.Form1. Article author. value+ "\ n";
}
if (document.Form1. Article topic. Value! = "") {
checkstr+= "article topic:" +document.Form1. Article topic. value+ "\ n";
}

if (document.Form1. hide the domain. Value! = "") {
Checkstr+=document.Form1. hidden fields. Value;
}
if (checkstr! = "") {
alert (CHECKSTR);
return false;
}
else return
return true;
}
</script>

<form name= "Form1" onsubmit= "MyCheck ()">

<input name= "article author" type= "Text" class= "textbox" id= "article author" >

<input name= "article theme" type= "text" id= "article topic" class= "TextBox" >

<input name= "hidden domain" type= "hidden" id= "hidden Field" value= "article Added success!" >

It should be noted that the JS code I identified should be consistent with the code name in the HTML. Note that the value followed by JS Form1 should also be consistent with the name value in the HTML.

Second, get the value of the drop-down list

<script type= "Text/javascript" >
function MyCheck () {
var Val1,val2,val3;
Val1=document.form1.address.value;
Val2=document.form1.class1.value;
Val3=document.form1.huxing.value;
Alert ("Get drop-down list value: \ n lot:" +val1+ "\ n Listings Category:" +val2+ "\ n Listing Type:" +val3);
}
</script>

<form name= "Form1" onsubmit= "MyCheck ()" >

and (a) broadly similar, can be combined with application

<script type= "Text/javascript" >
function MyCheck () {
var checkstr= "Get content as follows: \ n";
var var1,var2,var3;
Var1=document.myform.project_cat1_id.value;
Var2=document.myform.project_cat2_id.value;
Var3=document.myform.project_cat3_id.value;
Var4=document.myform.score_reguired.value;

if (Document.myform.score_reguired.value! = "") {
Alert (checkstr+= "project:" +var1+ "\ n Category:" +var2+ "\ n Assessment content:" +var3+ "\ n Get the number of points:" +VAR4);
}
if (Document.myform.score_reguired.value = = "") {
Alert ("The number of points must not be empty!") ");
}
if (Document.form1. hide domain. Value! = "") {
Checkstr+=document.form1. Hidden fields. Value;
}

if (checkstr! = "") {
alert (CHECKSTR);
return false;
}
else return
return true;
}
</script>

JS Get text Box value

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.