Need javascript to find text string on a page

Carl Dula
Carl Dula used Ask the Experts™
I have a dynamically created web page that is loaded. When the submit button is clicked I need a javascript to search the source of the page for a string like "CUSTOM CONFIGURATION". If it finds the string I need to call another page ( If it does not find it, then just process the submit.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
May I suggest other approach. Try to put some value in hidden input field like this (which would be equal to you having "CUSTOM CONFIGURATION" string on the page):


<form name="yourform" id="yourform" action="anotherpage" method="POST" onSubmit="check()">
<input type="hidden" name="custom" id="custom" value="1" />

<script type="text/javascript">
function check(){
          if ((document.yourform.onsubmit()) && (document.getElementById('custom').value==1))

Open in new window

If your form's onsubmit calls a function formSubmit() as:

<form name="form1" action="/submit/page" method="POST" onSubmit="formSubmit()">

Add the following to formSubmit():

function formSubmit()
    if (document.body.innerHTML.match(/CUSTOM CONFIGURATION/i))
Nether solution was subitable given the restrictions I was under. Did find another way to do it. Thanks for the ideas.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial