generalFunction.js 1.21 KB
Newer Older
1
2
3
4
5
6
7
8
// password requirement
function checkPasswordReq(pwd) {
    if (pwd.length < 8) {
        isBest = false;
    } else {
        isBest = true;
    }
    return isBest
Rosanny Sihombing's avatar
Rosanny Sihombing committed
9
10
11
12
13
14
15
16
17
18
19
}

// to get the queries of the URL
function getQueryStringParams(params, url) {
    // first decode URL to get readable data
    var href = decodeURIComponent(url || window.location.href);
    // regular expression to get value
    var regEx = new RegExp('[?&]' + params + '=([^&#]*)', 'i');
    var value = regEx.exec(href);
    // return the value if exist
    return value ? value[1] : null;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
}

/**  GO TO TOP Button **/
//Get the button:
var myTopBtn = document.getElementById("topBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() { scrollFunction() };
function scrollFunction() {
    if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
        myTopBtn.style.display = "block";
    } else {
        myTopBtn.style.display = "none";
    }
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
    document.body.scrollTop = 0; // For Safari
    document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}