x1nick Posted August 9, 2009 Share Posted August 9, 2009 Hi May have noticed recently was asking for html syntax javascript highlighting and got this working 100% Now as this is build into my CMS I need something to check that the tags are closed when the user presses save. Basically the user can use tags like this {if error} {else} {/if} {foreach details} {/foreach} I need to make sure that the user has added the closing tag for every opening tag they have entered. (can be more than one!) Whats the best approach to this through javascript? Quote Link to comment Share on other sites More sharing options...
x1nick Posted August 16, 2009 Author Share Posted August 16, 2009 Bump? Quote Link to comment Share on other sites More sharing options...
haku Posted August 17, 2009 Share Posted August 17, 2009 You can try storing opening tags in an array, and then when the closing tag is found, remove the opening tag from the array. When doing validation, check to see if there are any elements in the array. If there are, the user hasn't closed all of their tags. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.