2

I have a text area with HTML content,now i want to search there for specified text,if text area contains the text i need to return TRUE or FALSE.

also is there any way to check that a specified DOM is on that TEXT AREA [WITH HTML CONTENT] ?

Ex :

<html>
<head>
</head>
<body background="" bgcolor="red">
</body>
</html>

So now i want to check that the BODY tag have Background or bgcolor,if it contains i need to return true,how can i do this ? Actually i am trying to build a UI for editing HTML,if the html area contain

Thank you.

2 Answers 2

1
var text = $('#textarea').val();
var regex = /.../;
var found = text.match(regex);
if (found != null){return 1}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use indexOf, see the following example here: http://jsfiddle.net/mikhailov/S5jaz/2/

html

<textarea id="txt">
  Here I am
</textarea>

JS

var txt = $('#txt').val();
var word1 = txt.indexOf('Heref') != -1;    // false
var word2 = txt.indexOf('Here I') != -1;   // true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.