Javascript Regex IE8 issue -


i have div defined below:

<div id="bookmark_error" class="text-error">character '' not allowed in bookmark name.</div> 

by default hidden defined below:

$("#bookmark_error").hide(); 

some of characters not allowed while saving bookmark on page e.g. < , >

here validation check performed @ time of bookmark save:

... var bookmark_name = $("#bookmarks-form").find('input[type=text]').val(); var skipchars = ["<", ">", "&lt;", "&gt;", "&lt", "&gt", "&#60;", "&#62;", "&#60", "&#62"];                 (var i=0; < skipchars.length; i++){                     var skipchar = skipchars[i];                     while(bookmark_name.indexof(skipchar) != -1){                         $("#bookmark_error").html($("#bookmark_error").html().replace(/'[^]*'/g, "'"+skipchar+"'"));                         $("#bookmark_error").show();                         return;                     }                 } ... 

but not working expected in ie8 browser. doing wrong in javascript regex?

here sample value-input-value:

value : character '' not allowed in bookmark name.

input : <

value : character '<' not allowed in bookmark name.

input : >

output : character '>' not allowed in bookmark name.

you need add \d in regex work on ie8

reference : regex not working in ie8

so code this

$("#bookmark_error").html($("#bookmark_error").html().replace(/'[^\d]*'/g, "'"+skipchar+"'")); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -