Sankareswari Muthiah
Sankareswari Muthiah
Computer Science
29 Aug 2018

Real time use of user defined exception in Java

To know the real time use of user defined exception in java! 

29 Aug 2018

@Sankareswari - Any question that is not properly described is deleted from the site. Please add more information to your question (reply below) so that we can keep the question in the list. 

Sankareswari Muthiah

Sankareswari Muthiah

Computer Science
29 Aug 2018

real time use of user defined exception for example in facebook if we entered age below 15 it gives message like that I want some more real time uses.

29 Aug 2018

It's not Java, it's JavaScript that's doing all the magic. When user enters an invalid input in the text input box, JavaScript keeps checking it - and if the input is invalid, it will throw an exception. 

The exception can be user defined. You can define any message that you want to show just below the text box. 

Also, the rules can be customized. For example, you could have following rules -

  • Length of the input
  • Minimum and Maximum value (for example, age could be between 18 and 60)
  • Whether the input text is a valid email ID
  • Whether the input text is a valid phone number

and so on. 

I'll recommend checking out Parsley JS Validation library. Keep in mind that it's the JavaScript, not the Java that's doing stuff on the front end.

There ARE ways to do this using Java on the server side. In that case, you will have to fire AJAX requests to the server in real time and get the response. It's not an efficient method of validating input fields, though. 

I hope this helps.

Share this content on your social channels -

Only logged in users can reply.