Hi,
I want to validate data grd contents , some of the validations which I want to do is
1. When save button is clicked the system should not allow blank fields
2. Combo boxes in data grid
3. DTP pickers
please send me some code for these validations
Thnaks in Advance,
A.Durga Prasad
Loading
durga prasadPosted May 17, 2008, 1:58 AM
I should not be using java script in my project, is there any other way to overcome this
problem.
Thanks in Advance,
A.Durga Prasad
Niradhip ChakrabortyPosted May 16, 2008, 2:26 PM
You can do it using javascript. call this java script function on click of save button.
say dgrdDayEnd is name of my datagrid. strEmail,strTxtCtrlName name of my textbox.
I have done it for textbox do it for other control in same way.
function btnClick(){
var obj = window.document.getElementById("dgrdDayEnd")
var intLoop;
var intRowCnt;
if(window.document.getElementsByName("dgrdDayEnd").length !=0) {
intRowCnt = obj.rows.length ;
for(intLoop=1;intLoop<=intRowCnt;intLoop++){
if (intLoop < 9){
var strTxtCtrlName = 'dgrdDayEnd_ctl0' + (intLoop+1) + '_txtDayEnd';
var strCtrlName = 'dgrdDayEnd_ctl0' + (intLoop+1) + '_chkDayEnd';
var strEmail = 'dgrdDayEnd_ctl0' + (intLoop+1) + '_txtEmail';
}
else{
var strTxtCtrlName = 'dgrdDayEnd_ctl' + (intLoop+1) + '_txtDayEnd';
var strCtrlName = 'dgrdDayEnd_ctl' + (intLoop+1) + '_chkDayEnd';
var strEmail = 'dgrdDayEnd_ctl' + (intLoop+1) + '_txtEmail';
}
if (Trim(document.getElementById(strEmail).value) != '' && !isEmail(Trim(document.getElementById(strEmail).value))){
alert("Enter Valid Email Address ");
document.getElementById(strEmail).focus();
document.getElementById(strEmail).select();
return false;
}
if(window.document.getElementById(strTxtCtrlName).disabled == false){
if(window.document.getElementById(strTxtCtrlName).value == "" ||window.document.getElementById(strTxtCtrlName).value == 0){
alert("Please enter the No of Copies for DayEnd/No of Copies");
document.getElementById(strTxtCtrlName).focus();
document.getElementById(strTxtCtrlName).select();
return false;
}
}
}
}