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

When using <body onload=foo()>, the function foo will not be executed

Having trouble with this code - it seems like initialize() is not being called. Check out the code here Any insight into why this might be happening? ...

Loop through the JSON data to generate clickable links in the innerHTML

I've been searching through various resources for a solution to the issue I'm facing. My goal is to iterate through a JSON object and extract all the ids and corresponding dates from each top_worst section. The structure of the JSON data is as fo ...

Utilizing Cell References in the Table Component of React Material UI

I'm exploring React and aiming to create an editable table that dynamically updates the $/Unit cell based on changes in the Price and Units cells. I'm having trouble figuring out how to access values from other cells. Can this be achieved using ...

No reaction when utilizing the .post() method in jQuery

I've set up a basic form for users to update their status message. The form is functioning properly, but I'm encountering an issue where I am not receiving any response upon submission (using firebug, the response after submit is empty). Below i ...

Is there a way to programmatically emulate Firebug's inspect element feature using JavaScript?

Is there a straightforward method in JavaScript or any popular libraries like YUI or jQuery to allow users to interact with elements on a website, similar to the functionality of Firebug for developers? ...

Adding information to the MagicSuggest input by simply clicking a button

I have integrated MagicSuggest into a form and it's performing well. However, I am looking to enhance its functionality by allowing users to add data through a button click. Although my current method adds the data successfully, I encounter an issue ...

Using JavaScript to convert the text within a div into negative HTML code

I am working with this specific div: <div class="signs" id="signs" onclick="toggle()">&#43;</div> It currently displays the positive sign. I have set up a JavaScript function that is triggered when the div is ...

Enhancing Website Navigation with Active Tab Using JQuery

On my webpage, I have multiple tabs such as Features, Overview, Images, and more. What I aim to achieve is to hide the Feature tab and its content when there is no content available. Only Overview and Images tabs should be visible with Overview being the a ...

Issues with Angular ngroute: controllers are not functioning properly

In order to route my application with different themes on the same page, I plan to utilize the ngroute module. Here's an example of how I intend to achieve this: <html> <head> <title>Angular JS Views</title> ...

Leveraging server-sent events (SSE) for real-time updates on a web client using JavaScript

I have been experimenting with server-side events (SSE) in JavaScript and Node.JS to send updates to a web client. To simplify things, I created a function that generates the current time every second: setTimeout(function time() { sendEvent('time&a ...

persistently drifting towards the right despite the absence of direction

Why is the adminbox floating when no command is present? The fixed div center is not functioning properly .adminbox { width: 200px; height: 17px; margin-top: 20px; padding: 20px; font-size: 12px; ...

Dealing with click events on layers with z-index positioning

In the map application I am developing, I have implemented 2 z-index layers. However, a problem arises when attempting to zoom in by clicking on these layers. The click handler is located on the lower z-index layer and I do not want it to execute when a co ...

React - Error: Unable to access the 'props' property because it is undefined

I am working on implementing a click event to delete an item from my list, but I keep encountering the error message "TypeError: Cannot read property 'props' of undefined" whenever I click on it. Although I am striving to follow ES6 standards as ...

The value in the textarea will stay unchanged even after the form has been submitted

I recently resolved my previous issue, but now I am seeking advice on how to prevent a textarea from clearing its input after submitting a form. You can view the jsFiddle here: http://jsfiddle.net/rz4pnumy/ Should I modify the HTML form? <form id="for ...

Why does `npm init react-app` automatically select yarn as the default package manager? (npm version 6.14.5)

After executing the command npm init react-app, I noticed that npm automatically selects yarn as the default package manager for the newly created app. To resolve this, I followed the steps provided in How Do I Uninstall Yarn to remove yarn from my system. ...

Is there a way to include e.preventDefault() within an ajax call?

After the user clicks the submit button on my form, the handleSubmit function is triggered. However, I am having trouble calling e.preventDefault() inside my AJAX call due to its asynchronous nature. How can this issue be resolved? class FormRegister ex ...

The attempt to initiate the MongoDB server was unsuccessful. dbexit reported an error with code 48 within the MongoDB system

After updating MongoDB, I encountered an error. I attempted to restart the MongoDB service, but the error persists. ...

Ways to send information to browser javascript from Spring MVC controller

Looking for the most efficient method to transfer data from Spring MVC to JavaScript. Let's say there is an array in JavaScript: var myArray = new Array(); And in the Java backend, there is another array: int[] myArray = new int[100]; What would ...

Styling a div element in CSS with absolute positioning and the ability to

I am looking to set specific positions and dimensions for the div elements within my HTML document. Refer to this image for reference: https://i.stack.imgur.com/ANBVm.png For each of these div elements, I want a vertical scrollbar to appear if the content ...

Struggling to make the fancybox feature function with html/php

I've been trying to find a solution to this problem repeatedly, but I just can't seem to crack it. All I want to do is use fancybox to display an image. Since this is my first time using fancybox, I'm sure someone with more experience will ...