google apps script - Mandatory attribute not working in html webapp -
i using html webapp form , fields selected mandatory (required) able submit data without updating required fields.
below detailed html , gs script, me fix concern
<script> function submitform(btnclicked) { $("button").attr("disabled", true); var jsonobj = {}; jsonobj["project name"] = $("#projectname").val(); jsonobj["updatebtn"] = $(btnclicked).text(); google.script.run.withsuccesshandler(aftersaving).savedate(jsonobj); } function aftersaving() { alert("thanks, response has been recorded"); $("button").attr("disabled", false); } </script> <form action="" method="get"> <div class="container"> <table class="table table-bordered" width="" style="width:54%"> <thead> <tr class="one"> <th width="33%"> project name </th> </tr> </thead> <tbody> <tr> <td><div class="form-group txt"> <input name="" type="text" placeholder="" class="form-control input-md" id="projectname" required="required"> </div></td> </tr> </tbody> </table> </div> <div class="container"> <div class="col-md-2 col-md-offset-5"> <div class="form-group"> <button style="display:block;width:100%" id="updatebtn" name="singlebutton" class="btn btn-success" type="submit" onclick="submitform()" >save</button> </div> </div> </div>
you need remove onclick="submitform()" , instead add onsubmit="submitform()" in form tag.
<form onsubmit="return submitform()"> also, add return false; submitform function.
Comments
Post a Comment