...

View Full Version : field testing for blank



Cindy
07-02-2003, 06:13 PM
How would I change the following two lines to test the first field to see if it is blank and if it is not - to then test the second field to make sure it is not blank. If the first field isn't blank and the second field is blank then I need to output an error.

if ( objForm.form_transaction_forward.value == 'Correction' )
{
if (!chkNotNull(objForm.form_forward_date, 'text', 'You must enter your comments')) return false;
}
else
return true;

joh6nn
07-02-2003, 08:32 PM
i'm not quite sure i understood that. could you explain it again? also, it's much easier to help out, if we can see all the code; could you link to the page this would be on?

Cindy
07-02-2003, 08:54 PM
The following is my error checking code. I need to add an additional field check to this. I have a field called "form_forward_email_name". I need to test this field to see if it is blank. If it is - no more testing is required. If it is not blank, I then need to test another field called "form_forward_end_date". This field cannot be blank if the first field called "form_forward_email_name" is not blank. Basically if one of these fields has data in it, then the other one must have data in it.

<!--
function frmCheck (objForm){
if (!chkNotNull(objForm.form_employee_first_name, 'text', 'You must enter the employee first name')) return false;
if (!chkNotNull(objForm.form_employee_last_name, 'text', 'You must enter the employee last name')) return false;
if (!chkNotNull(objForm.form_requestor, 'text', 'You must enter your name')) return false;
if (!chkNotNull(objForm.form_manager_name, 'text', 'You must enter the manager name')) return false;
if (!chkNotNull(objForm.form_department_account, 'text', 'You must enter the department account number')) return false;
if (!chkNotNull(objForm.form_HR_representative, 'text', 'You must enter the HR representative name')) return false;
if (!chkNotNull(objForm.form_transaction_type, 'select', 'You must enter the transaction type')) return false;
if (!chkNotNull(objForm.form_employee_location, 'select', 'You must enter the location')) return false;
if (!chkNotNull(objForm.form_pctype, 'select', 'You must enter type of PC')) return false;
if (!chkNotNull(objForm.form_requestor_email, 'select', 'You must enter your email address')) return false;

if ( objForm.form_transaction_type.value == 'Correction' )
{
if (!chkNotNull(objForm.form_comments, 'text', 'You must enter your comments')) return false;
}
else
return true;
}
// -->


Thanks for responding.

arnyinc
07-02-2003, 10:14 PM
All the negatives are blowing my mind (if not not null, return false) and I can't see the code for chkNotNull() so I might reverse the logic on one of these. That's easy enough for you to switch around though. Just add this line in right below the if statement you have for the email address (form_requestor_email).

if ((!chkNotNull(objForm.form_forward_email_name, 'text', 'You must enter your email name'))&&(!chkNotNull(objForm.form_forward_email_name, 'text', 'You must enter your email name'))) return false;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum