Tuesday 12 October 2021

How to validate URL address with and withour IP addresss in JavaScript/jquery

 //////// CSS

<style>

.validated_ok{border:1px solid green}

.validated_error{border:1px solid red}

.validated_okT{color:green}

.validated_errorT{color:red}

</style>

//////////////// HTML

<input type="text" class="cf_required" style='width:80%' name='website'>

<br>

<span id="urlsv"></span>

 

/////////////JS 

 

<script>

    $(document).ready(function () {

        $(".cf_required[name='website']").focusout(function () {

            console.log("Hi");

            var myVariable = $(this).val();

            var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol

                '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|' + // domain name

                '((\\d{1,3}\\.){3}\\d{1,3}))' + // ip (v4) address

                '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + //port

                '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string

                '(\\#[-a-z\\d_]*)?$', 'i');

            if (pattern.test(myVariable)) {

                $("#urlsv").html("Msg: Valid");

                $("#urlsv").addClass("validated_okT").removeClass("validated_errorT");

                $(this).addClass("validated_ok").removeClass("validated_error");

                console.log("Hello");

            } else {

                $("#urlsv").html("Msg: Inalid");

                $("#urlsv").removeClass("validated_okT").addClass("validated_errorT");

                $(this).removeClass("validated_ok").addClass("validated_error");

                console.log("bye");

            }

        });

    });

</script>

 

///////////////// Result


 

 



Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...