There are two possible cases. Use the ext control and asp control for analysis.
1. If it is an asp control, you must obtain the id of the current control when prompted. You can obtain the corresponding options by querying the source code.
.
2. If it is an ext control, prompt a certain option to directly obtain the id of the control in the aspx design.
Use the following js functions to prompt.
Copy codeThe Code is as follows:
<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("txtName ")! = Null ){
If (document. getElementById ("txtName"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("txtName"). focus ();
Return false;
}
}
Return true;
}
</Script>
First: asp control judgment Information
Copy codeThe Code is as follows:
<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("the current textbox id in the source code ")! = Null ){
If (document. getElementById ("id of the textbox in the source code"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("the current textbox id in the source code"). focus ();
Return false;
}
}
Return true;
}
</Script>
Front-end display of asp control
Copy codeThe Code is as follows:
<Table>
<Tr>
<Td> name: </td>
<Td> <asp: TextBox id = "txtName"/>
<Td> <asp: Button onClientClick = "return YANDNCheck ();"/>
</Tr>
</Table>
Second: ext control judgment Information
Copy codeThe Code is as follows:
<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("txtName ")! = Null ){
If (document. getElementById ("txtName"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("txtName"). focus ();
Return false;
}
}
Return true;
}
</Script>
Ext control front-end display information: directly call the id of the corresponding control.
Copy codeThe Code is as follows:
<Table>
<Tr>
<Td> name: </td>
<Td> <ext: TextBox id = "txtName"/>
<Td> <ext: Button onClientClick = "return YANDNCheck ();"/>
</Tr>
</Table>