Friday, August 3, 2012

keep a form from posting with jQuery in the name of validations without putting something goofy and old school inline in the form tag

<script type="text/javascript" src="Scripts/jquery-1.5.1.js"></script>
<script type="text/javascript">
   $("form").submit(function () {
      var poc = $("#ctl00_LayoutWorkspace_POC").val();
      var title = $("#ctl00_LayoutWorkspace_ProjectTitle").val();
      if (poc == "") {
         $("#poc_warning").attr('style', 'color:Red;');
      } else {
         $("#poc_warning").attr('style', 'color:Red;display:none;');
      }
      if (title == "") {
         $("#title_warning").attr('style', 'color:Red;');
      } else {
         $("#title_warning").attr('style', 'color:Red;display:none;');
      }
      if (poc == "" || title == "") {
         return false;
      } else {
         return true;
      }
   });
</script>

No comments:

Post a Comment