Generates a string id (specified length) of random characters using javascript.

Posted by Somesh Shinde On Monday, 17 April 2017 0 comments
This script will be useful for those who wants a unique ID in String.




Run this script by calling to function from html:- makeid(8)
<script>

function makeid(l) { var text = ""; var char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for(var i=0; i < l; i++ ) { text += char_list.charAt(Math.floor(Math.random() * char_list.length)); } return text; }

console.log(makeid(8)); //check in console 8 character unique id will generate.

</script>

READ MORE