new form vs edit form
Posted: 30 Mar 2015
i have working validation js for newform. i try to copy same js for edit form but didnot work? is there a difference?
below is my code.
fd.onsubmit(function() {
if(!fd.field('Title').value().trim()) {
alert('Please, fill in the Project Name field.');
$('.projectname input').focus();
return false;
}
else if(!fd.field('Asset_x0020_ID_x0020_Numbers').value().trim()) {
alert('Please, fill in the Asset ID Numbers field.');
$('.assetid input').focus();
return false;
}
else if (fd.field('Project_x0020_Manager').value().dictionaryEntries.length == 0) {
alert('Please, fill in the Project Manager field.');
return false;
}
else if(!fd.field('AFH_x0020_Type').value()) {
alert('Please, select in the AFH Type field.');
return false;
}
else if(!fd.field('StartDate').value()){
alert('Please, fill the start Date.');
$('.startdate input').focus();
return false;
}
else if(!fd.field('Completion_x0020_Date').value()){
alert('Please, fill the Completion Date.');
$('.compdate input').focus();
return false;
}
else if(!fd.field('Related_x0020_Information').value()) {
alert('Please, fill in the related information field.');
$('.relatedinfo textarea').focus();
return false;
}
else if(!fd.field('Basic_x0020_Description').value()) {
alert('Please, fill in the basic information field.');
$('.basicdesc textarea').focus();
return false;
}
else if(!fd.field('MOC_x0020_Number').value()) {
alert('Please, fill in MOC Number field.');
$('.moc input').focus();
return false;
}
else if(!fd.field('Justification').value()){
alert('Please, fill the justification field.');
$('.just input').focus();
return false;
}
return true;
});
below is my code.
fd.onsubmit(function() {
if(!fd.field('Title').value().trim()) {
alert('Please, fill in the Project Name field.');
$('.projectname input').focus();
return false;
}
else if(!fd.field('Asset_x0020_ID_x0020_Numbers').value().trim()) {
alert('Please, fill in the Asset ID Numbers field.');
$('.assetid input').focus();
return false;
}
else if (fd.field('Project_x0020_Manager').value().dictionaryEntries.length == 0) {
alert('Please, fill in the Project Manager field.');
return false;
}
else if(!fd.field('AFH_x0020_Type').value()) {
alert('Please, select in the AFH Type field.');
return false;
}
else if(!fd.field('StartDate').value()){
alert('Please, fill the start Date.');
$('.startdate input').focus();
return false;
}
else if(!fd.field('Completion_x0020_Date').value()){
alert('Please, fill the Completion Date.');
$('.compdate input').focus();
return false;
}
else if(!fd.field('Related_x0020_Information').value()) {
alert('Please, fill in the related information field.');
$('.relatedinfo textarea').focus();
return false;
}
else if(!fd.field('Basic_x0020_Description').value()) {
alert('Please, fill in the basic information field.');
$('.basicdesc textarea').focus();
return false;
}
else if(!fd.field('MOC_x0020_Number').value()) {
alert('Please, fill in MOC Number field.');
$('.moc input').focus();
return false;
}
else if(!fd.field('Justification').value()){
alert('Please, fill the justification field.');
$('.just input').focus();
return false;
}
return true;
});