Validation message java script issue

I need to change tab color when required field is blank.

I am checking existing code in suiteCRM. It is available in core file but get “tabView” array is blank.

so code is not working and same “clear_all_errors” not working when we have updated single field and Do “Save”.

Please Help me.

Please tell me

  • your SuiteCRM version

  • exactly which module, which view, are you trying to change?

In “Account” module. I am using “Tab” Layout in Editview . In 2nd Tab “Industry” field is required.

If I am trying to save but “Industry” value is blank so I want to highlighted colour with “Tab Name” or any alert like “Please Submit Required field in Next Tab”…

So I am checking " validate_form" function at file /include/javascript/sugar_3.js

Here one function “add_error_style”
inside this function get “tabView” params .
but following lines are not working:


if (tabView.get) {
					var tabs = tabView.get("tabs");
					for (var i in tabs) {
						if (tabs[i].get("contentEl") == parentDiv || YAHOO.util.Dom.isAncestor(tabs[i].get("contentEl"), inputHandle)) {
							tabs[i].get("labelEl").style.color = "red";
							if (inputsWithErrors.length == 1)
								tabView.selectTab(i);
						}
					}
					if (typeof selectTabOnErrorInputHandle == 'function') {
						selectTabOnErrorInputHandle(inputHandle);
					}
				}

please check if it is possible from core file then this functionality work for all editview.

You shouldn’t be doing customizations there, they will not be upgrade-safe. Every change you make should be only in the Custom folder:

https://pgorod.github.io/Custom-folder/

The correct way to have validations and changes in views would be to override the view class and inject some javascript. See an example here

https://suitecrm.com/suitecrm/forum/developer-help/6921-viewedit-validation

I know this is unupgrade-safe changes.I don’t want to do this.

I have done all the changes in custom folder but my new requirement is : "When field is required and click save button then Blank field “TAB Name” colour will be change.

So I want to field related tab name then I can add js in custom.

That’s why I have referred core file and found this code. but this code is not working so please suggest me good way…

I did suggest a “good way” to do it. Try getting that example to work for you, inject some javascript into the view.

I don’t know the exact answer to do what you want, but try that example and then explore from there.

Hi,

I am using custom validation method.

In this function I am checking only required field.

I am getting all field name. I am using “Tab” view for Edit view I have 6 different “Tab”.
Now I want to Tab Name based on field.

I have tried following YUI function:

Any one please help me for which function need to use and get correct “Tab Name”?

Sorry, I don’t know…

Maybe you can find out by debugging Javascript on your browser when you click to change Tab?

P.S. - this might help: https://gist.github.com/jmertic/2564483

I have tried provided function : var tab0 = EditView_tabs.getTab(0);

and debug but result is “undefined”

I was tried all possible way but I am getting only blank params.

If you can try and find any single function for get Tab Name then Please send me.

Thanks

Hi @kishah2411 how did you go with this? I also have same question