new form vs edit form
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;
});
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
There are no differences in working with new and edit forms. So, make sure that you've assigned the CSS-classes that you use in your code e.g. projectname, assetid etc to the appropriate fields. Also, open the browser console and check whether JS-errors or notifications appear there when you submit the form.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 21 guests