Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:19:05+00:00 2026-06-01T03:19:05+00:00

I want to validate a text area for img tag when it is duplicated.

  • 0

I want to validate a text area for img tag when it is duplicated. example, if i entered the image tag with src i should enter the same source with tag again i need to show alert how it could be done. my snippet to check whether the image is there or not. but i need to do for above validation also…

function validateEditor() {

    var editor_val = $('#asset_html').val(), iSrc;

    // Check for empty string
    if(!string_IsEmpty(editor_val)) { 

        // Check whether img is available
        if(editor_val.match(/img/g)) {

            var src_cnt = (editor_val.match(/img/g).length);
            //console.log(editor_val.match(/src/g).length);

            $('#asset_html_preview').html(editor_val);

            for(var j = 1; j <= src_cnt; j++) {

                if($('#asset_html_preview img:nth-child(1)').attr('src')) {

                    iSrc = $('#asset_html_preview img:nth-child(1)').attr('src');

                    if(iSrc.indexOf('http://') != -1) { 

                        $('#asset_html_preview img:nth-child(' + j + ')')
                            .error(function() { alert('Check ur image src'); });
                        //break;

                    } 
                }
            }
        }       
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:19:07+00:00Added an answer on June 1, 2026 at 3:19 am

    You may be looking for this:

    var arr = {};
    var $div = $('<div />').html($('textarea').val());
    $div.find('img').each(function (i) {
            var src = $(this).attr('src');
    
            if (src.indexOf('http://') >= 0 && arr[src] == undefined) {
               arr[src] = 'foobar';
            } else if (arr[src] !== undefined) {
               alert('This url `' + src + '` already exists');     
            } else {
               alert('This url `' + src + '` is wrong');     
            }  
     });
    

    Demo: http://jsfiddle.net/LXgWU/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate Winforms text box with regex. The input sting example: ZX1
If I want to validate that a text box contains an integer greater than
I want to validate the value a user enters in a text box, so
i want a regular expression to validate string to have only text,operators and these
I'm using jquery validate to validate my forms. I want to show a text
I want to validate a text box that doesn't accept any special characters using
I want to validate my text are while entering data. I had written code
I want to validate my text field with a YYYY format, meaning a user
I want to validate email text for which I am using RegexKitLite.h . I
I'm writing application in which I need to validate text entered by user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.