HTML page
Copy Code code as follows:
<form onsubmit= "if (confirm) (' Make sure you fill in the right, or you will be wrong! ') {return checkform ();} Else{return false;} ">
<table >
<tr>
<td> Select sender <font class= "Red" >*</font></td>
<td>
<input type= "text" Name= "sendto_type[]" id= "Sendto_type1" value= "1" > Sent by city
</td>
</tr>
<tr>
<td> Select sender 2<font class= "Red" >*</font></td>
<td>
<input type= "text" Name= "sendto_type[]" id= "Sendto_type1" value= "1" > Sent by city
</td>
</tr>
</table>
</form>
JS Code
Copy Code code as follows:
<script>
Function Checkform () {
pass = true;
$ (' Td:contains (' * ') '). Next (). Find ("input"). each (function () {
if (this.value = = ') {
Text = $ (this). Parent ( ). Prev (). text ();
Alert (text+ "is required");
This.focus ();
Pass = false;
return false;//out each
}
});
Return pass;
}
</script>