Fri, 17 May 2024


How to write a JavaScript function which checks for special symbols with regular expression?

By: Peter, NetArt Media
Thu, 29 April 2021

<script>


function ContainsSpecialSymbols(strInput)
{

// put here whatever symbols you might need to check
var reg = new RegExp("#|%");

if (reg.test(strInput))
{

return true;

}
else
{

return false;

}

}

alert(""+ContainsSpecialSymbols("exam#mple"));


Category: Javascript
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox