Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Tuesday, May 9, 2023

Format Numbers in Currency Format in React

export const dollarsignlocale = Intl.NumberFormet('en-US', {

    style: 'currency',

    currency: 'USD',

    minimumFractionDigits: 2,

    maximumFractionDigits: 2

});


If want only formatting not sign then 


export const dollarsignlocale = Intl.NumberFormet('en-US', {

     minimumFractionDigits: 2,

    maximumFractionDigits: 2

});

Monday, December 4, 2017

Encrypt JavaScript and jquery using php

Now we have a problem that we want to encrypt javasctript and jquery.

I create a code for encryption of JavaScript or jquery using php.


Have a look On git repo:-
https://github.com/ankitgarg306/javascriptencrypt

Wednesday, August 23, 2017

Only number will taken in text box using javascript

if you want only number will be taken in the text box. so we will use this formet for javascript.


$(document).on('keyup','.numbersOnly', function() {
     this.value = this.value.replace(/[^0-9\.]/g,'');
});

Monday, May 1, 2017

How can you check for a #hash in a URL using JavaScript?

if we are using ajax and on the response we want to know the url has # or not. so by this code we can find it it have the # on the url or not.


Method 1:-
if(window.location.hash) {
  // Fragment exists
} else {
  // Fragment doesn't exist
}


Method 2:-
if (location.href.indexOf("#") != -1) {
        // Your code in here accessing the string like this
        // location.href.substr(location.href.indexOf("#"))
    }


Method 3:-

var url = 'example.com/page.html#anchor',
    hash = url.split('#')[1];

if (hash) {
    alert(hash)
} else {
    // do something else
}

Method 4:-
  
var requestedHash = ((window.location.hash.substring(1).split("#",1))+"?").split("?",1);

Friday, December 9, 2016

After ajax form submit value from ckeditor textarea is not sent through post

try

for (instance in CKEDITOR.instances) {
        CKEDITOR.instances[instance].updateElement();
    }

<script src="ckeditor/ckeditor.js"></script>
function savedata() 
{
    for (instance in CKEDITOR.instances) {
        CKEDITOR.instances[instance].updateElement();
    }

    jQuery.ajax({
        type: 'POST',
        url: 'data_save.php',
        data: $("#frmdata").serialize()
     });  
     return false; 

 }

Tuesday, April 19, 2016

Slick carousel. Want autoplay to play the slides

Html:-
<div class="column-right slide">
    <div><img src="img/servicios/road.jpg" alt="Road"/></div>
    <div><img src="img/sobre_mi/map.jpg" alt="Map"/></div>
</div>


JS:-
var slider = $('.slide').slick({
    autoplay: true,
    autoplaySpeed: 1000,
    dots: false,
    infinite: false,
    speed: 1000,
    fade: true,
    slide: 'div',
    cssEase: 'linear',
    onAfterChange: function(){
        //check the length of total items in .slide container
        //if that number is the same with the number of the last slide
        //Then pause the slider
        if( item_length == slider.slickCurrentSlide() ){
            //this should do the same thing -> slider.slickPause();
            slider.slickSetOption("autoplay",false,false)
        };
    }
});