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

Question

Question

Regex to change display format of date from SQL lookup

asked on September 27, 2018

I have a table in a form with a drop down field that populates dates from a SQL lookup. As expected, the date form that populates is this:

However, I would prefer to have only the date display. I've been tinkering with the "regex replace" method to achieve this, but either this is not the right method or the code is problematic; my skill level is low. Thank you in advance for any thoughts or corrections.

$(document).ready(function () {
{
$('.changeDate select').change(function(){
  var reg = $(this).val();
  $(this).val(reg.replace('\d{1,2}\/\d{1,2}\/\d{4}'));
}
})
});

 

0 0

Replies

replied on September 27, 2018 Show version history

Try to use .match instead of .replace

$(document).ready(function () {
{
$('.changeDate select').change(function(){
  var reg = $(this).val();
  $(this).val(reg.match(/\d{1,2}\/\d{1,2}\/\d{4}/));
}
})
});

 

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

Sign in to reply to this post.