Ramco Ramco

Ramco Ramco

  • 464
  • 2.8k
  • 402.4k

Semantic/Foundation/Bootstrap Validation

Jun 4 2021 12:01 PM
Hi
 
How we can implement any of the above validations or like below link with the given code
 
https://www.dotnetcurry.com/jquery/1168/validate-form-jquery-bootstrap-validator
  1. <table class"table table-striped table-bordered" style="width:100%" id="tblLocation">  
  2. <thead>  
  3. <tr>  
  4. @*<th><input type="checkbox" id="checkall" /></th>*@  
  5. <th>  
  6. Id  
  7. </th>  
  8. <th>  
  9. Description  
  10. </th>  
  11. <th>  
  12. IsActive  
  13. </th>  
  14. <th>Action</th>  
  15. </tr>  
  16. </thead>  
  17. <tbody class="tbody"></tbody>  
  18. </table>  
  19. <script src="~/Scripts/Appjs/Location.js"></script>  
  20. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">  
  21. <div class="modal-dialog">  
  22. <div class="modal-content">  
  23. <div class="modal-header">  
  24. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>  
  25. <h4 class="modal-title">Add New Location</h4>  
  26. </div>  
  27. <div class="modal-body">  
  28. <div class="form-horizontal">  
  29. <div class="form-group">  
  30. <label class="control-label col-sm-3" for="Id">Id</label>  
  31. <div class="col-sm-2">  
  32. <input type="text" class="form-control form-control-sm" id="txtId" placeholder="Id">  
  33. </div>  
  34. </div>  
  35. <div class="form-group">  
  36. <label class="control-label col-sm-3" for="Description">Description</label>  
  37. <div class="col-sm-9">  
  38. <input type="text" class="form-control form-control-sm" id="txtDescription" placeholder="Description">  
  39. </div>  
  40. </div>  
  41. <div class="form-group">  
  42. <label class="control-label col-sm-3" for="PType">Product Type</label>  
  43. <div class="col-sm-2">  
  44. <input type="text" class="form-control form-control-sm" id="txtPType" placeholder="Product Type">  
  45. </div>  
  46. </div>  
  47. </div>  
  48. </div>  
  49. <div class="modal-footer">  
  50. <button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();">Save</button>  
  51. <button type="button" class="btn btn-primary" id="btnUpdate" style="display:none;" onclick="Update();">Update</button>  
  52. <button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>  
  53. </div>  
  54. </div>  
  55. </div>  
  56. </div>
  1. function Add() {  
  2. var res = validate();  
  3. if (res == false) {  
  4. return false;  
  5. }  
  6. var objLocation = {  
  7. Id: $('#txtId').val().toUpperCase(),  
  8. Description: $('#txtDescription').val().toUpperCase(),  
  9. IsActive: $('#txtIsActive').val().toUpperCase()  
  10. };  
  11. $.ajax({  
  12. url: "/Location/Add",  
  13. data: JSON.stringify(objLocation),  
  14. type: "POST",  
  15. contentType: "application/json;charset=utf-8",  
  16. dataType: "json",  
  17. success: function (data) {  
  18. //loadData();  
  19. $('#tblLocation').DataTable().ajax.reload();  
  20. $.notify(data.message, {  
  21. globalposition: "top center",  
  22. //position:"center",  
  23. className:"success"  
  24. })  
  25. $('#myModal').modal('hide');  
  26. },  
  27. error: function (xhr, ajaxOptions, thrownError) {  
  28. alert("Error");  
  29. $("#msgModalBody").html('Status : ' + xhr.status + ' Error : ' + thrownError);  
  30. $("#msgModal").modal('show');  
  31. //  
  32. }  
  33. });  
  34. }  
Thanks

Answers (1)