[SOLVED] Javascript syntax issue

I’m trying to error check on certain fields onBeforeInsert. When record_type_id is selected certain fields are shown using sc_block_display. If record_type_id = 1 and the field that is displayed when the block is shown is null then throw error. That part works, but when I close the error popup and proceed to enter a value in the field that was null and save I get the same error. There is now data in this field and it’s not null so why is the error showing again. My syntax must be incorrect or maybe it needs to be in other events as well? Also, if I use && instead of || the error never executes. I really need AND to work because OR isn’t really applicable here:confused:

if ({record_type_id} == '1' || {tax_amount} == 'null')
	{
		$error_message3 = 'Please enter a tax amount';
		sc_error_message($error_message3);
		}
	
elseif({record_type_id} == '2' || {invoice_amount} == 'null')
	{
		$error_message4 = 'Please enter an invoice amount';
		sc_error_message($error_message4);
		}

I figured it out. You have to separate the statements in their own ().

if (({record_type_id} == '1') && ({tax_amount} == null))
	{
		$error_message3 = 'Please enter a tax amount';
		sc_error_message($error_message3);
		}
	
elseif(({record_type_id} == '2') && ({invoice_amount} == null))
	{
		$error_message4 = 'Please enter an invoice amount';
		sc_error_message($error_message4);
		}