jQuery: How to check if the content has any URLs

Sam Hanson

I need to restrict the URL postings in the textarea.

For this I used the code:

    var url_act = jQuery("#area").val();
    var matches = url_act.match(/http:/);

    if (matches)
    {
        alert('You didn\'t have permission to post any url');
        return false;
    }

But if the content has any https: or url starts with www. is not restricted.

How to restrict if the content has any URL formats or not? If the URL is capital letters is not working.

Is there any way to do this?

Avinash Raj

Change your regex to,

var matches = url_act.match(/https?:|\bwww\./i);

i modifier helps to do a case-insensitive match.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to check if folder has any content in puppet

From Dev

How to check if the page has content?

From Java

Check if any ancestor has a class using jQuery

From Dev

jQuery check if any text input has value

From Dev

Check if a git repository has any content that is not present in a remote

From Dev

How to check if json array has any value?

From Dev

How to check if any attribute has changed on a model

From Dev

How to check if any attribute has changed on a model

From Dev

How to check if a batch file has ANY parameters?

From Dev

How to check if json array has any value?

From Dev

How to check if XElement has any child nodes?

From Dev

How to check to see if wordpress shortcode has $content

From Dev

How to check the equality of two identical URLs if one of them has "www"?

From Dev

jQuery check if any div on page has specific class in an if statement

From Dev

Check whether a li element has any children with value using jQuery

From Dev

Check if DataInputStream has content

From Dev

How to check if it exists any ajax pending with jQuery?

From Dev

How to check if any child exist in jquery

From Dev

How to check if url has no query string in jQuery?

From Dev

how to check if a ul has a particular li with jQuery?

From Dev

How to check the table has value using Jquery

From Dev

how to check if a ul has a particular li with jQuery?

From Dev

How to check if url has no query string in jQuery?

From Dev

XSLT how to check if the current node has any attribute or not

From Dev

How to check if a table has any duplicated rows column in js?

From Dev

How to check if any span element in inside div has empty value

From Dev

How to check if a woocommerce product has any category assigned to it?

From Dev

How to check if a file has an extension (any extension) with regular expression in Bash?

From Dev

How to check if a channel has any messages? Discord.py

Related Related

  1. 1

    How to check if folder has any content in puppet

  2. 2

    How to check if the page has content?

  3. 3

    Check if any ancestor has a class using jQuery

  4. 4

    jQuery check if any text input has value

  5. 5

    Check if a git repository has any content that is not present in a remote

  6. 6

    How to check if json array has any value?

  7. 7

    How to check if any attribute has changed on a model

  8. 8

    How to check if any attribute has changed on a model

  9. 9

    How to check if a batch file has ANY parameters?

  10. 10

    How to check if json array has any value?

  11. 11

    How to check if XElement has any child nodes?

  12. 12

    How to check to see if wordpress shortcode has $content

  13. 13

    How to check the equality of two identical URLs if one of them has "www"?

  14. 14

    jQuery check if any div on page has specific class in an if statement

  15. 15

    Check whether a li element has any children with value using jQuery

  16. 16

    Check if DataInputStream has content

  17. 17

    How to check if it exists any ajax pending with jQuery?

  18. 18

    How to check if any child exist in jquery

  19. 19

    How to check if url has no query string in jQuery?

  20. 20

    how to check if a ul has a particular li with jQuery?

  21. 21

    How to check the table has value using Jquery

  22. 22

    how to check if a ul has a particular li with jQuery?

  23. 23

    How to check if url has no query string in jQuery?

  24. 24

    XSLT how to check if the current node has any attribute or not

  25. 25

    How to check if a table has any duplicated rows column in js?

  26. 26

    How to check if any span element in inside div has empty value

  27. 27

    How to check if a woocommerce product has any category assigned to it?

  28. 28

    How to check if a file has an extension (any extension) with regular expression in Bash?

  29. 29

    How to check if a channel has any messages? Discord.py

HotTag

Archive