Bootstrap form validation solution

Utilizing bootstrap validation to validate a jsp page.

The folder structure is as follows:

WebContent
├── bootstrap-form-validation
├── js
└── pages

All three folders are under the web content. If I create another folder called teacherDetails under the pages folder to place my jsp files, the validation does not work properly. However, when the jsp file is moved out of the pages folder or placed directly under webcontent, it works fine. For this project, it must be in the pages folder. Please assist me with this issue. My jsp code is as follows:

 <html lang="en">
  <head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">

  <!-- Optional theme -->
 <link href="<%=request.getContextPath()%>/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">  
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
  <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="<%=request.getContextPath()%>/bootstrap-form-validation/style.css" rel="stylesheet">

 <link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/bootstrap-datetimepicker-master/css/datetimepicker.css">
  <script src="<%=request.getContextPath()%>/twitter-bootstrap/twitter-bootstrap-v2/js/bootstrap-modal.js"></script>
     <script src="<%=request.getContextPath()%>/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.min.js"></script>
</head> 


 <script type="text/javascript">
$(function() {
    $('#datetimepicker4').datetimepicker({
        pickTime : false
    });
});
 </script>


   <script>
        $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );
  </script>


   <script>
function profileDetails() {
    document.getElementById("profiledetails").submit();

}
function profileCancel() {
    document.getElementById("profileDetails").reset();
}
   </script>




    <style>

   .no-space [class *="span"] {
margin-left: 0 !important;
width: 25% !important;
//
This
is
for
4
elements
ONLY
in
the
row
     }


   </style>


     <body>






        <form class="well form-horizontal" id="create_teacher" method="post" action="">
            <div style="height: 850px;">
                <div style="width: 104%; margin-top: -20px;">

                    <fieldset>
                        <legend style="color: #333;">&nbsp;&nbsp;&nbsp;Teacher Information</legend>
                </div>
                <br> <br>
                <div style="margin-left: 140px">
                <div class="form-group">
                    <label for="uln" class="control-label">Teacher Id:</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">
                            <input type="text" class="form-control" name="teacherId"
                                id="teacherId">
                        </div>
                    </div>
                </div>
                <br> 
                <div class="form-group">
                    <label for="name" class="control-label">Name :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="text" class="form-control" name="teacherName"
                                id="teacherName">
                        </div>
                    </div>
                </div>
                <br> 

                <div class="form-group">
                    <label for="gender" class="control-label">Gender:</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <select class="form-control" name="gender">
                                <option></option>
                                <option>Male</option>
                                <option>Female</option>

                            </select>
                        </div>
                    </div>
                </div>

                <br> 



                <div class="form-group">
                    <label for="dob" class="control-label">Date Of Birth(DOB) :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">
                            <input type="date" class="form-control" name="dob" id="date">
                        </div>
                    </div>
                </div>
                <br> 

                <div class="form-group">
                    <label for="dob" class="control-label">Date Of Join:</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">
                            <input type="date" class="form-control" name="doj" id="date">
                        </div>
                    </div>
                </div>
                <br> 

                <div class="form-group">
                    <label for="name" class="control-label">Education :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="text" class="form-control" name="teacherName"
                                id="education">
                        </div>
                    </div>
                </div>
                <br> 

                <div class="form-group">
                    <label for="name" class="control-label">Experience :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="text" class="form-control" name="teacherName"
                                id="experience">
                        </div>
                    </div>
                </div>
                <br> 

                <div class="form-group">
                    <label for="name" class="control-label">Prev Employee details :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="text" class="form-control" name="teacherName"
                                id="prevdetails">
                        </div>
                    </div>
                </div>
                <br> 


                <div class="form-group">
                    <label class="control-label">Photo :</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="file"  />
                        </div>
                    </div>



                </div>
                <br> 

                <div class="form-group">
                    <label for="name" class="control-label">Email Id:</label>
                    <div class="col-xs-8">
                        <div class="col-lg-8">

                            <input type="email" class="form-control" name="teacherName"
                                id="email">
                                <p class="help-block"></p>
                        </div>
                    </div>
                </div>
                <br> 
                <div class="control-group">
                    <label class="control-label"></label>
                    <div class="controls">
                        <div style="margin-left: 150px">
                            <input type="submit" class="btn btn-primary" value="Submit"
                                onclick="profileDetails();" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="button" class="btn btn-primary" value="Cancel"
                                onclick="cancelProfile();" />
                        </div>
                    </div>
                </div>
                </div>
                </fieldset>
            </div>
        </form>


   <script src="<%=request.getContextPath()%>/bootstrap-form-validation/assets/js/jquery-1.7.1.min.js"></script> 

    <script src="<%=request.getContextPath()%>/bootstrap-form-validation/assets/js/jquery.validate.js"></script> 

    <script src="<%=request.getContextPath()%>/js/script.js"></script> 
 <script>
    addEventListener('load', prettyPrint, false);
    $(document).ready(function(){
    $('pre').addClass('prettyprint linenums');
        });
     </script> 
</body>
 </html>

Answer №1

Your hyperlinks are set to relative paths

<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">

Relative links will look for the specified folder at the same level as the current location. For example, if your JSP files are stored in a folder named "teacherDetails" under "pages", the link will search for the "bootstrap" folder within the "pages" folder.

To refer to folders outside of the current level, you need to specify it like this:

<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
The "./" represents the current folder, "../" will point to the parent folder, and so forth.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble resolving a setInterval problem with JavaScript?

Yesterday, I learned about the setInterval function which allows me to execute a task or function after a specific amount of time. While I have successfully implemented the interval in my code, it keeps adding new lines with the date each time. What I re ...

eliminating and adding a node

Is there a way to replace the existing span elements inside the div (<div id='foo'>) with newly created nodes? I have been looping through all the children of the div, using removeChild to remove each node, and then appending a new node in ...

Retrieve a list of all file names within a designated directory using Angular

I am working on my Angular app and I need to list all the file names inside the assets folder. To achieve this, I am planning to utilize the npm library called list-files-in-dir https://www.npmjs.com/package/list-files-in-dir Here is the service impleme ...

Unusual Behavior Observed in JavaScript Map Reduce

var t = [-12, 57, 22, 12, -120, -3]; t.map(Math.abs).reduce(function(current, previousResult) { return Math.min(current, previousResult); }); // returns 3 t.map(Math.abs).reduce(Math.min); // returns NaN I'm puzzled as to why the second variant ...

The POST request did not yield an HttpResponse object; instead, it returned None

When I submit a selection from a dropdown form to views as a POST request, and then use this selection to query data from Django, I encounter an issue while trying to map Django models data to Highcharts following this approach. The error message "the view ...

How can I modify the orientation of the arrow and switch sides in a dropdown submenu?

I am working on creating a menu with dropdown-submenu functionality using CSS. .dropdown-menu { float:left; } .left-submenu { float: none; } .left-submenu > .dropdown-menu { border-radius: 6px 0px 6px 6px; left: auto; margin-lef ...

How long does it take to delete and recreate a cloudfront distribution using AWS CDK?

I am currently undergoing the process of migrating from the AWS CDK CloudfrontWebDistribution construct to the Distribution Construct. According to the documentation, the CDK will delete and recreate the distribution. I am curious about the total duration ...

Angular fails to include the values of request headers in its requests

Using Django REST framework for the backend, I am attempting to authenticate requests in Angular by including a token in the request headers. However, Angular does not seem to be sending any header values. Despite trying various methods to add headers to ...

React Router Blank Page Conundrum

In a new project, I'm experiencing an issue where the content is not loading in despite using a similar React-Route setup that worked in a previous project. When I create a nav link in the root directory, it changes the path but the screen remains whi ...

Trigger an alert when a button is clicked and redirect the user to an newly opened tab

I recently created a button with a link that opens in a new tab. I also implemented some JavaScript to display an alert. Everything is working as expected, but after the user clicks "OK" on the alert, they remain on the same page. I would like to automati ...

Ways to organize JSON data from a fetch request into multiple divisions

I have written a JavaScript code to fetch JSON information. I plan on storing this JSON file locally (I downloaded an example file and added a birthdate object for my usage example from https://jsonplaceholder.typicode.com/users) My goal is to parse the r ...

Verifying user authorization for Microphone access prior to triggering event in React application

I have created a React component featuring a microphone button that operates as follows: OnMouseDown => Initiates audio recording by the user OnMouseUp => Ceases audio recording To elaborate, while the button is pressed down, the user can continue ...

Discovering the key to selecting a row by double-clicking in Vuetify's v-data-table

I'm having trouble retrieving the row by event in my v-data-table. It only gives me the event and remains undefeated. How can I catch items in the v-data-table? <v-data-table :headers="showHeaders" :page="page&quo ...

I recently installed Bootstrap 5 and jQuery 3.6 on my website, but I'm encountering an issue where the dropdown button is not functioning properly when I try to embed them. Could there be

I have this code: I recently downloaded Bootstrap 5 and JQuery 3.6, but I am facing an issue where the dropdown button is not working when I embed them in my project. Can you take a look at my code to see if anything is missing? <head> <ti ...

Passing Data from Child to Parent Components in ReactJS

I'm new to React and JavaScript, currently working on a website. I've encountered an issue with passing data between components from child to parent. Here's the scenario: In my App.js script, I'm using react-router-dom for routing. I ...

Mixing React with jQuery in Gatsby: Incorporating jQuery Plugins into Your Gatsby Site

Previous description has been omitted as it is no longer relevant. I recently set up a new gatsby site and successfully integrated jquery, bootstrap, wow, and owl carousel. layout.js import './expose' import './main' expose.js impo ...

Dynamic jQuery menu with sliding animation

Currently, I am in the process of developing a jQuery dropdown menu and things are going well so far. The only issue I am facing is that once a folder or tree is opened, there doesn't seem to be a way to close it again. I have a hunch that using EQ or ...

JavaScript - Modify the proposed content prior to inserting it into the input field

In my current project, I have implemented a feature using jQuery UI - v1.11.4, where an HTML textbox utilizes a JavaScript autocomplete functionality. The suggested string for the textbox is created by concatenating several columns (patient_no, patient_nam ...

Issue with the loop function

When I try to loop through my code, I keep getting the same "y" value (5) and it doesn't change. What I actually want is to make the ajax call repeat X times [all], passing both the response and the current call number through an anonymous function. A ...

unexpected alteration of text sizing in mathjax within reveal.js presentations

Something strange is happening with the font size in my slides. The code for each slide is the same, but there is an unexpected change between the 3rd and 4th slide. I cannot figure out what is causing this discrepancy. Oddly enough, when I remove the tit ...