Validate Required fields on submit
function validate(){
//1-get all input with attr (isReq=true)
//2-check if the input contain data.
//-2a-if it contain data set req control to display ” else display *
var ctrlId = ”;
$.each($(‘:input’), function(Index, ctrl) {
if (ctrl.isReq == ‘true’) {
//get the control id and see if it has any data
ctrlId = ctrl.id;
var x = ‘#lblmsg_’+ ctrlId
var value = $(‘#’+ ctrlId).val()
if(value.length > 0) {
$(‘#lblMsg_’+ ctrlId).attr({
value:”
});
}
else
{
$(‘#lblMsg_’+ ctrlId).attr({
value:‘*’
});
}
}
});
}
//HTml ——————————————————————————————————–
<tr><tdcolspan=”2″><inputtype=button value=”validate” onclick=”javascript:validate();”/>
<inputtype=buttonvalue=”Submit” onclick=”javascript:SendForm();”/></td>
<tdclass=”style1″colspan=”2″><inputid=”txttest”name=”txttet”type=textisReq=”true”value=”"/>
<inputid=”lblMsg_txttest”name=”lblMsg_txttest”type=textvalue=”"/></td>
</tr>
//end Html——————————————————————————————————