0

I was trying a simple Try It editor and i wanted to know that how do i validate the code that the user has entered be it HTML or a script , how do i know if it has any errors? also, are there any library's for doing that

Harshit Laddha
  • 2,044
  • 8
  • 34
  • 64
  • 1
    Check here for JS validation https://github.com/jshint/jshint – elclanrs Jul 30 '13 at 04:21
  • okay ty got it , btw any clues for HTML syntax checking too....? – Harshit Laddha Jul 30 '13 at 04:23
  • HTML here http://validator.w3.org/ – elclanrs Jul 30 '13 at 04:24
  • no but if i use w3.org wont it require internet connection always, as what i am trying to do here (sorry did not mention it earlier) is make an local app and so i want offline options for validating the syntax, and i saw some such validators in some text editors i use but could not figure out how they work – Harshit Laddha Jul 30 '13 at 04:37

3 Answers3

1

I just check stackoverflow, and found this one,maybe it helps you.

var xml = 'Caleb';
var parser = new DOMParser();
var doc = parser.parseFromString(xml, 'text/xml');

Check for XML errors using JavaScript

Community
  • 1
  • 1
coonooo
  • 205
  • 1
  • 4
0

you also used to javascript error using firbug extension is used to show error javascript.

you get firebug using that link
http://getfirebug.com/
Renish Khunt
  • 5,620
  • 18
  • 55
  • 92
0

if you are using chrome, then use google developer tools (press ctrl+shift+i), there you will find various options in the tab like ELEMENT(to see html code, styles of your document),CONSOLE(you will find errors and warning there), this is very useful, try and explore this one only.

schnill
  • 905
  • 1
  • 5
  • 12
  • no actually what i wanted to do was ask the user to write some script on the fly and then the backend will process it for any errors so chrome developer tools wont help there i feel – Harshit Laddha Jul 30 '13 at 04:35