Answered by:
submit data using Jquery/Javascript during button click

Question
-
submit data using Jquery/Javascript during button click
- Edited by trulyChaitu Thursday, March 19, 2015 4:26 PM
Friday, March 13, 2015 3:00 PM
Answers
-
Hi,
From your description, my understanding is that you want to restrict edit form with jQuery/JS.
If you want to restrict the default edit form with jQuery/JS, you could refer to these steps below:
- Enter your editform.aspx.
- Add below code under <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">.
- Save this file.
<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> <script type="text/javascript"> function PreSaveAction(){ if($("select[id$='DropDownChoice']").val()==""){ alert("please choose a value!"); return false; } return true; } </script>
The screenshot below is my result(it will not save data after clicking OK in the message alert):
If you customize your list with InfoPath, you could check the checkbox “Cannot be blank” under Validation section or add a rule for your validation as the screenshot below:
In addition, you could check your code with pressing F12 to debug your code.
Best Regards,
Vincent Han
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Murugesa Pandian Tuesday, March 17, 2015 4:24 AM
- Marked as answer by Rebecca Tu Thursday, March 26, 2015 7:56 AM
Tuesday, March 17, 2015 2:43 AM
All replies
-
Why don't you use the default validation of sharepoint? (Column validation or Form Validation).
it's the easiest and quickest way to achieve that.
If you really want to use javascript/jQuery, use the "PreSaveAction" function
function presaveaction(){ if($('.yourDropDown').val() == "") return false; }
when you return false on that function, the form is not saved.Friday, March 13, 2015 3:52 PM -
return false; is not working
- Edited by trulyChaitu Friday, March 13, 2015 7:12 PM
Friday, March 13, 2015 6:06 PM -
Hi,
From your description, my understanding is that you want to restrict edit form with jQuery/JS.
If you want to restrict the default edit form with jQuery/JS, you could refer to these steps below:
- Enter your editform.aspx.
- Add below code under <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">.
- Save this file.
<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> <script type="text/javascript"> function PreSaveAction(){ if($("select[id$='DropDownChoice']").val()==""){ alert("please choose a value!"); return false; } return true; } </script>
The screenshot below is my result(it will not save data after clicking OK in the message alert):
If you customize your list with InfoPath, you could check the checkbox “Cannot be blank” under Validation section or add a rule for your validation as the screenshot below:
In addition, you could check your code with pressing F12 to debug your code.
Best Regards,
Vincent Han
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Murugesa Pandian Tuesday, March 17, 2015 4:24 AM
- Marked as answer by Rebecca Tu Thursday, March 26, 2015 7:56 AM
Tuesday, March 17, 2015 2:43 AM