*

umimo

  • ***
  • 88 posts
Ad publish title
« on: June 01, 2022, 06:42:38 PM »
Hi,

How can i make Ad publish title not required for one category?

i want change required category base

 $("form[name=item]").validate({
                rules: {
                    "title[<?php echo osc_current_user_locale(); ?>]": {
                        required: false,
                        minlength: 5
                    },

*

MB Themes

Re: Ad publish title
« Reply #1 on: June 01, 2022, 07:11:05 PM »
You would have to use validation via class (still jquery validate) and add/remove this class on category change.
But I am not sure if it is achievable.
Maybe using minlength as variable that value change on category change
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

umimo

  • ***
  • 88 posts
Re: Ad publish title
« Reply #2 on: September 06, 2022, 08:04:21 AM »
You would have to use validation via class (still jquery validate) and add/remove this class on category change.
But I am not sure if it is achievable.
Maybe using minlength as variable that value change on category change



Maybe using minlength as variable that value change on category change

    function title_required(){
 if ($cat_id == $title_required_cat) {
  return true
} else {
  return false;
}}

how to use catId variable outside

 $('body').on('click change', 'input[name="catId"], select#catId', function() {
      var cat_id = $(this).val();
      console.log(cat_id)

      })

 

 $("form[name=item]").validate({
        rules: {
          "title[<?php echo osc_current_user_locale(); ?>]": {
            required:  <?php echo title_required(); ?>,
         
          },

« Last Edit: September 06, 2022, 08:08:28 AM by umimo »

*

MB Themes

Re: Ad publish title
« Reply #3 on: September 06, 2022, 02:13:14 PM »
catId is ID, not name.
I recommend you to take it from different point of view.
For category, where title is not required, generate it by yourself and hide input. Otherwise, show input and erase generated title.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots