4

I'm looking for a C# function which returns true if a string contains valid javascript syntax.

For instance:

IsValidJavascript("alert('hello');");

would return true, but

IsValidJavascript("alertXXhelloZ);");

would return false.

Blachshma
  • 17,097
  • 4
  • 58
  • 72
shamp00
  • 11,106
  • 4
  • 38
  • 81

1 Answers1

6

You'll need to use an interpreter.
You can try Jint which is a Javascript interpreter for .NET.

Blachshma
  • 17,097
  • 4
  • 58
  • 72