The W3C has explicit [guidelines for web content accessability][1], including contrast. You can compare color values to their ratio and tell the user if their color choices are likely inaccessible/unreadable.

> The visual presentation of text and images of text has a contrast ratio of at least 4.5:1

Note there are exceptions and some good guidance in the full set of guidelines. If you're doing something so simple as checking whether white or black is most readable, **comparing the contrast ratio is the easiest way**. Note that this may not always result in ideal colors if black and white are the only text options.

Here's a great tool to let you to [test contrast in text][2]. You can get a good idea of what is checked for in color accessibility and consider giving your users a display somewhat like that; present the text on their chosen background, and **consider giving them a warning message if their text is considerably below the readability threshold**.


  [1]: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast
  [2]: http://www.snook.ca/technical/colour_contrast/colour.html