How to use GlideAjax in on submit client script

KARAN24
Tera Contributor

Hi Team,

I have to do a validation on one variable called tax id ,if the tax id  does not exists in account table ,it  clear out the value, and is happening with On change client script.But it should not allow to submit the form.But form submission is possible.How can we validate that field on oN Submit.

 

Thanks,

Karan

13 REPLIES 13

Hi @Ankur Bawiskar ,

I am using the below lines:

g_form.clearValue('u_party_tax_id');
 
g_form.showFieldMsg('u_party_tax_id', 'Please enter Valid Tax ID','error',true);
 }
But also the form is getting submitted,even though the field is mandatory.

@KARAN24 

are you sure it's getting set as mandatory true?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Yes,its getting mandatory.

 

@KARAN24 

then form should not get submitted without mandatory field being populated since you are clearing the field value?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

As it is OnChange client script,so it is not validating if the value is not changed.

if we enter the value and directly click on submit button,the form is getting submitted.

 

I guess we need to do something On Submit.

 

Thanks,

Karan