Validating an ISBN

How to get this to work in your own page

Insert the following snippets to get the JSF ISBNValidator to work in your JSP page. Note since this is a validator it uses the validator tag to set itself up. Note more information about the validator can be found in the API documentation.

This demo does not require you to enter an ISBN, if you do not enter an ISBN it will return to the same page without giving an error. However if you do enter some values for the ISBN it will call the validator to validate the ISBN. The input field here requires you to enter the ISBN without any dashes, because we are not using the ISBNConverter companion class.

    <h:inputText value="#{isbnBean.isbn}">
        <f:validator validatorId="com.manorrock.jsf.isbn.validator.ISBNValidator"/>
    </h:inputText>

    

Actual demo

Enter an ISBN: