$ ("#subjectId option:selected"). Text ();//Gets the selected value based on the SELECT Tag ID value
$ (' input[name= ' Knowledgepointname "]). Val ();//Get value values based on input tag name
$ ("#knowlistId"). attr ("value");//input tag ID Get value
$ ("div.q-option:checked"). Length;//checkbox tag based on class to determine if greater than 0 is selected to select otherwise less than 0
JSP page
<div class= "col-sm-9" id= "Pointchild" >
<input type= "text" name= "Pointname" class= "col-xs-10 col-sm-5" value= ""/>
</div>
<div class= "col-sm-6" id= "Knowledgedesc" >
<textarea id= "Content" class= "Ckeditor-inline" name= "Pointdesc" ></textarea>
</div>
<button id= "Commit" class= "btn Btn-info" type= "submit" > Submit </button>
JS Code
<script type= "Text/javascript" >
$ ("#commit"). Click (function () {
var pointname=$ (' Input[name= ' pointname "] '). Val ();
var oeditor = ckeditor.instances.content;//Get editor textarea value content is the TEXTAREA ID value
if (pointname.length==0) {
var spanexist= $ ("#pointParent"). Find ("span");//Locate the span tag under Pointparent to prevent continuous click submission resulting in multiple-hop error messages
if (spanexist.length>0) {//delete if there is a word
$ ("#pid"). Remove ();//delete span label
}
var para=document.createelement ("span");
Para.id= "pid";
Para.innerhtml= "Test Center can not be empty";
var Element=document.getelementbyid ("Pointchild");
Element.appendchild (para);
document.getElementById ("pid"). style.color= "Red";
}
if (oeditor.getdata () = = "") {
var spanexist= $ ("#pointParent"). Find ("span");
if (spanexist.length>0) {
$ ("#did"). Remove ();
}
var para=document.createelement ("span");
Para.id= "did";
Para.innerhtml= "Test Center description cannot be empty";
var Element=document.getelementbyid ("Knowledgedesc");
Element.appendchild (para);
document.getElementById ("did"). style.color= "Red";
}
if (pointname.length==0 | | Oeditor.getdata () = = "") {//Judging as long as one of the label's text is empty the form does not commit false for not committing
return false;
}
});
</script>
Here is the selector get list of values
Selector instance selection
*$ ("*") all elements
#id$ ("#lastname")id= elements of "LastName"
. class$ (". Intro") all elements of class= "Intro"
Element$ ("P") all <p> elements
. Class.class$ (". Intro.demo") all class= "Intro" and Class= "demo" Elements
: First$ ("P:first") <p> Element
: Last$ ("p:last") final <p> element
: Even$ ("Tr:even") all even <tr> elements
: Odd$ ("tr:odd") all odd <tr> elements
: EQ (Index)$ ("UL Li:eq (3)") in the list of fourth elements (index starting from 0)
: GT (NO)$ ("UL li:gt (3)") lists elements with index greater than 3
: LT (No)$ ("UL Li:lt (3)") lists elements with index less than 3
: Not (selector)$ ("Input:not (: Empty)") all input elements that are not empty
: Header$ (": Header") all heading elements
: Animated all animated elements
: Contains (text)$ (": Contains (' W3school ')") contains all elements of the specified string
: Empty$ (": Empty") all elements of No Child (element) node
: Hidden$ ("P:hidden") all hidden <p> elements
: Visible$ ("table:visible") for all the viewable tables
S1,S2,S3$ ("Th,td,.intro") all elements with a matching selection
[Attribute] $ ("[href]") all elements with href attribute
[Attribute=value] $ ("[href= ' # ']") all href attribute values equal to "#" elements
[Attribute!=value] $ ("[href!= ' # ']") all href attribute values are not equal to "#" elements
[Attribute$=value] $ ("[href$= '. jpg ']") all href attribute values contain elements that end with ". jpg"
: Input$ (": input") all <input> elements
: Text$ (": Text") all type= "text" <input> elements
:p assword$ (":p assword") all type= "password" <input> elements
: Radio$ (": Radio") all type= "Radio" <input> elements
: CheckBox$ (": checkbox") all the <input> elements of the type= "checkbox"
: Submit$ (": Submit") all type= "Submit" <input> elements
: Reset$ (": Reset") for all type= "reset" <input> elements
: Button$ (": Button") for all type= "button" <input> elements
: Image$ (": Image") all the <input> elements of the type= "image"
: File$ (": File") all the <input> elements of the type= "file"
: Enabled$ (": Enabled") all active input elements
:d isabled$ (":d isabled") all disabled input elements
: Selected$ (": Selected") all selected input elements
: Checked$ (": Checked") all selected input elements
This article from "has been climbing the pit" blog, declined reprint!
form validation and get tag values and CKEditor textarea judgment is empty