How to replace charecter “/” to “-” from string using jquery.
I want as below:
06/01/2013 to 06-01-2013
In My Case:
I am taking a value from input box
<input id="from-date" value="06/01/2013" name="from-date"/>
fdate = $("#from-date").val();
fdate.replace('/','-');
console.log(fdate);
but it return same string(06/01/2013).
You don’t need jQuery but the standard replace function with the proper regex syntax :
Note that
replacedoesn’t change the string you pass but returns a new one. Note also you need to pass thegflag so that all occurrences are replaced.