CrazyEngineers
  • Real time use of user defined exception in Java

    Updated: Oct 26, 2024
    Views: 1.3K

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

    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorAug 29, 2018

    #-Link-Snipped-# - 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. 

    Are you sure? This action cannot be undone.
    Cancel
  • Sankareswari Muthiah

    MemberAug 29, 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.

    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorAug 29, 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.

    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register