You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Currency Minimum/Range

posted on October 11 Show version history

I hope in the next version of Forms (currently on 10.2.1) that there is a way to set the minimum or range value on a currency field.  Currently we can set it to required but if I need it also to be greater than $0.00 or within a range, it's not an option.  I understand I can use javascript to accomplish this but in a table (like an expense report), that coding can be tedious (especially for non-coding customers) for something that is available in the number field.  Has anyone found an easy way to verify a currency value is greater than 0.00 outside of assigning classes to each currency field and adding JS to verify it every time they change it?

1 0
replied on October 12

Thank you for the feature request. For now, use the JS solution. We have this request in our backlog for a future release.

1 0
replied on October 11

Something I just realised I didn't put any code in to handle table rows added via lookup... Give me 5 min and ill add that in.

1 0
replied on October 11

You ROCK!!!

0 0
replied on October 11

Hey mate,

You didn't mention what version of forms you are using so ive written this assuming 10.2. If you have anything before that let me know cause ill need to use different code. But this should do what you are after. :)

function validateCur(value)
{
  if(parseFloat(value.replace('$','')) >= 0.00)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function addValidator ()
{
  $('.currency').each(function() {
    var attr = $(this).attr('data-parsley-cur');
    if (typeof attr == typeof undefined || attr == false) {
    	$(this).attr('data-parsley-cur','');
	} 
  });

}

$(document).ready(function() {
  window.Parsley.addValidator('cur', {
  validateString: function(value) {
    return validateCur(value);
  },
  messages: {
    en: 'Currency must be greater then $0.00'
  }
});
 addValidator();
  $(document).on('click','.cf-table-add-row',function() {
    addValidator();
  });

});

 

2 0
replied on October 11

This one has support for rows added via lookup.

function validateCur(value)
{
  if(parseFloat(value.replace('$','')) >= 0.00)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function addValidator ()
{
  $('.currency').each(function() {
    var attr = $(this).attr('data-parsley-cur');
    if (typeof attr == typeof undefined || attr == false) {
    	$(this).attr('data-parsley-cur','');
	} 
  });

}

$(document).ready(function() {
  window.Parsley.addValidator('cur', {
  validateString: function(value) {
    return validateCur(value);
  },
  messages: {
    en: 'Currency must be greater then $0.00'
  }
});
 addValidator();
  $(document).on('click','.cf-table-add-row',function() {
    addValidator();
  });
  $(document).on('lookupcomplete', function(event){
    addValidator();
  });

});

 

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.