this is my code i want to have disable submit button after page load and enabled button when im typing in the textbox. pls help thanks
<div class="container" id="frmtoken">
<form method=POST action="authorize.php">
<div class="featured-desc-left">
<p>Enter token and wait to be connected.</p>
<p><strong>note: Only one device per token is allowed</strong></p>
</div>
<div class="two columns featured-desc-left">
<p><input type="text" name="token"></p>
</div>
<div class="featured-desc-left">
<p>
<input name="tconnect" type="submit" value="Connect"
onClick="this.form.submit(); this.disabled=true; this.value='Sending...';"/>
</p>
</div>
</form>
</div>
jQuery
$(document).ready(function(){
$("input[type=submit]").attr("disabled","disabled");
});
$("input[type=text]").on("keydown",function(){
$("input[type=submit]").removeAttr("disabled");
});
Bearing in mind this will apply to all submit inputs on the page when any text inputs on the page are typed in so you probably should assign classes/ids.
Related
after several hours looking for answer, I still haven't found a solution for my problem. I have a very basic form with some checkbox inputs. But the Submit Button doesn't open the php Script for processing the data.
Here's the form:
<form name="request" action="request.php" method="get">
<h2 id="sum">5.99€</h2>
<h6>Per Month</h6>
<input type="hidden" name="hide">
<!--The Hidden Input is there for testing purposes-->
<input type="submit">
</form>
And here's the full code of the section:
<section id="contact">
<div class="container">
<div class="col-lg-12 text-center">
<h2 class="section-heading">Ordering Form</h2>
<p class="text-muted">Choose some web essentials and add them to your plan
<br><a class="page-scroll">Get to know the essentials</a></p><br>
<form name="request" action="request.php" method="get">
<h2 id="sum">5.99€</h2>
<h6>Per Month</h6>
<input type="hidden" name="hide">
<!--The Hidden Input is there for testing purposes-->
<input type="submit">
</form>
<script type="text/javascript">
//Some JavaScript which doesn't have anything to do with the form
</script>
</div>
</div>
</section>
When i click the submit button its just doesn't do anything. No Error message, no 404, no PHP error.
Hope you can help me!
I'm building an Angular JS app with a 2-step form. It's really just one form, but uses JavaScript to hide the first panel and show the second when the user clicks the 'next' button and moves on to step 2. I have set 'required' validations on some of the fields in step 1, but obviously, they do not get validated when the user clicks the 'next' button...they get validated when the 'submit' button is clicked at the end of step 2.
Is there any way I can tell angular to validate those fields in the form when the 'next' button is clicked?
I suggest to use sub-forms. AngularJS supports putting one form inside another, and validity is propagated form lower form to upper;
Here is example: http://plnkr.co/edit/SruBmlGZZtbwiU8cktAp?p=preview
Here is some code so you can grasp the idea:
<form name='myform' ng-init="step = 1">
<div ng-show="step==1">
<h3>Step 1: Enter some general info</h3>
<div ng-form='step1form'>
Name: <input ng-model="name" required>
</div>
<button ng-disabled="!step1form.$valid" ng-click="step = 2">Next</button>
</div>
<div ng-show="step==2">
<h3>Step 2: Final info</h3>
<div ng-form="step2form">
Phone: <input ng-model="phone" required>
</div>
<button ng-click="step = 1">Prev</button>
<button ng-disabled="!myform.$valid" ng-click="submit()">Submit</button>
</div>
<div>
Validation status:
<div> Whole form valid? {{myform.$valid}} </div>
<div> Step1 valid? {{step1form.$valid}} </div>
<div> Step2 valid? {{step2form.$valid}} </div>
</div>
</form>
I'm unable to submit a form using method post.
The first error that occured was a 405 but I was able to solved it using this solution.
Now occurs a 403 error, how can I solve it?
JS
$(document).ready(function () {
$('#loginForm').submit(function () {
//some business logic...
$.mobile.changePage($('#menuPage'));
});
});
HTML
<div data-role="page" id="loginPage">
<div data-role="header"><h1>Login</h1></div>
<div data-role="content">
<form method="post" id="loginForm">
<fieldset>
<label for="utilizadorText">Inserir Utilizador</label>
<input type="text" id="utilizadorText" name="utilizadorText" />
<label for="palavraChaveText">Inserir Palavra Chave</label>
<input type="password" id="palavraChaveText" name="palavraChaveText" />
<input type="submit" id="loginAnchor" class="submit" value="Login" />
</fieldset>
</form>
</div>
</div>
<div data-role="page" id="menuPage">
<div data-role="header"><h1>Menu</h1></div>
<div data-role="content">
Menu
</div>
</div>
It appears as though you are trying to submit the form to the loginPage and than change the page to menuPage. This doesn't make sense to me. What actions are you trying to perform here? If you want to be able to take form data from the context of the loginPage and than apply business logic to it than the solution below might help.
Possible Solution #1
please help me someone,,,,
i write some code to get the popup window using the following code.
<div id="EMAIL_CONFIRMATION_PENDING" class="popupContact" style="z-index:10003;">
<div class="popup_textarea">
<h3><h:outputLabel value="#{labelMsgs.emailPendingLabel}"/></h3>
<div class="VerifyEmailText">
<h:outputLabel value="#{labelMsgs.clickToSendEmail}"/>
<span class="FontItalic"><h:outputLabel value="#{headerBean.emailAddress}."/></span>
<br /><br />
</div>
<div class="SuspendedBoxMsg">
<h:outputLabel value="#{labelMsgs.accountSuspend}"/><br />
<h3><h:outputLabel value="#{sessionScope.DASHBOARD_EMAIL_EXP_TIME}"/></h3>
<h:outputLabel value="#{labelMsgs.unlessYouVerify}"/>
<br />
</div>
<div>
<span class="FontWeight">
<h:outputLabel value="#{labelMsgs.spamMailFolder}"/>
</span>
<a4j:commandLink id="resendLink" styleClass="violet_color_link" value="#{labelMsgs.regSuccSendMail}" onclick="javascript:resendLink(); this.onclick=null;" action="#{headerBean.resendEmail}" />
</div>
<div class="OkButton">
<div class="button_input">
<a4j:commandButton id="emailConfm" styleClass="image_button" value="#{labelMsgs.okButton}" action="#{accntDashboardBean.popupRefresh}"
reRender="frmAccountDashboardMenu:POPUP_PANEL" oncomplete="disablePopup1('EMAIL_CONFIRMATION_PENDING', 'backgroundPopup');popupCall('#{sessionScope.toShowPopupOf}');"/>
</div>
</div>
</div>
</div>
in this am using the id of the div to populate the popup,like this i have write some other popup code with different ids. for this i write the code in window.onload function to get the popup,
so, i need to set the default focus on the submit button which i mentioned in the above code.
You can set the focus to the submit button with the use of JavaScript or jQuery:
JavaScript:
document.getElementById('emailConfm').focus();
jQuery:
$('#emailConfm').focus();
you can use the following to set focus into the button
document.getElementById('emailConfm').focus();
But this may not work, to fix this I have done something like this
setTimeout(function() { document.getElementById('emailConfm').focus(); },100);
You can use HTML form tag inside your div to set focus on Submit button.
Use your input tags inside form tag, so whenever you are entering User Name or Password Submit button is always focussed on press of Enter button.
<form>
<input type="text"/>
<input type="password"/>
<input type="submit"/>
</form>
i have the html as follows
<div class="element-container" id="div_3">
<div id="submit_submit" class="element">
<div class="fleft">
<input type="submit" value="Click me!" name="submit" id="submit"/>
</div>
<div class="clr"/>
</div>
</div>
When i click on element-container i want the label of submit button i.e. Click me!
Please give a solution , I've tried $('#submit').attr('value'). but i didn't get the result
There's a built-in method in jQuery for returning the value of INPUT elements, val(). The following should work:
$('#submit').val();
I've never tried it with a submit button specifically though.