After filling form with Watin the submit button remains disabled - javascript

I reask this question because no one could give a answer yet and the problem still remains. After filling a form the submit button remains disabled and I don't know how I can fix it. When I click with my mouse into one inputfield the disabled attribute of the Submit button disappears and it is clickable. I couldn't simulate this mouseclick by the Click() Method for this input field.
This is what I've tried yet:
browser.TextField(Find.ById("pvpnet-account-email")).Click();
browser.TextField(Find.ById("pvpnet-account-email")).Focus();
browser.TextField(Find.ById("pvpnet-account-email")).Select();
browser.TextField(Find.ById("pvpnet-account-email")).KeyDown();
browser.TextField(Find.ById("pvpnet-account-email")).KeyUp();
browser.TextField(Find.ById("pvpnet-account-email")).Change();
browser.TextField(Find.ById("pvpnet-account-email")).Blur();
How can I fix it ?

Related

Change form element invalid style when trying to submit with out click event

I'm trying to change the style of an element when it's invalid for example when marked as required but is empty.
So I tried this :
input:invalid {
background-color: red;
}
But because when page loads, all inputs are empty, all inputs become red. I only want my required inputs to become red when the user tries to submit.
So another solution was to add a class to inputs when trying to submit. Adding this class when clicking on the submit button by adding listener on button click event. Yet, you can also submit a form by pressing enter in a field so, class wouldn't be added to inputs.
We can see that the default invalid style gets applied only when we submit, even if we submitted by pressing enter. So I came to you to figure out a way to do the same but with my own style.

How to prevent find :submit to enable rest of the buttons in the form?

Hello I have form that has an option to enable/disable some fields. If user selects No as an option for particular section of the form all fields in that form will be disabled. However, I use this logic when saving form data:
frmObject.find(":submit").prop("disabled", true); // Disable submit button
then this code to enable submit button:
frmMessage.show().addClass(obj.CLASS).html("Error!").delay(7000).fadeOut('slow').queue(function(){
$(this).removeClass(obj.CLASS).dequeue();
frmObject.find(":submit").prop('disabled', false); // Enable submit button
});
Problem that I have after form is submitted and successfully saved code that enables submit button will affect other buttons in the form that should remain disabled. I'm not sure why since the other buttons have <button></button> tag and they do not have type=submit. Does anyone know how to prevent this behavior?
I'm not sure why since the other buttons have tag
and they do not have type=submit. Does anyone know how to prevent this
behavior?
The default type for <button> is submit. It's a good idea to always specify the type explicitly:
<button type="button">I'm NOT a Submit Button</button>
<button>I'm AM a Submit Button</button>

How to prevent double click in redux-form?

I have a form and some buttons which are not related to the form. Also I have a blur validation on fields of the form. When field of the form is focused and I'm clicking on none-form button first time I fire blur action of redux-form field. And only on second click the button onClick is working. I want to fire onClick of none-form button on first click(when redux-form field blur action is firing). What should I do?
UPD: So far the best option is to replace onClick with OnMouseDown

force the focus to leave a form field with jQuery in iOS when selecting non-input element

Using jQuery or something similar, is it possible to detect when a user has clicked away, effectively removed focus, from a form field in iOS? I have conventional form which has a first name, last name, address line 1, address line 2 etc.
On an iPad when you select a form field the only way to leave that form field is to select another field in the form by clicking it or by hitting the Previous or Next buttons in the keyboard pane.
As the keyboard pane is shown clicks to other non-input elements on the page are ignored, so focus remains on the form field.
Is there a way with jQuery/JavaScript (or anything else) to force the focus to leave the form field if I click away from it by clicking a non-input form element?
Here's an example of what I mean. In the screen below, when the focus is on the Line 1 element I can't move out of it by clicking a non-input element.
Try just doing a quick blur() on the form, that might work.
$('body').on('click', function () {
$('form').blur();
// And since you said selecting an anchor might help, potentially doing a:
$('a#whatever').blur(); // might do the trick too
});

Why does $.change() fire on a submit button?

I have a $.change() event, but when a submit button is pressed, the change event fires again. It is only supposed to fire once when a text is inputted into a input text box.
$('input:submit', top.document).bind('click', function (e) {
alert("submitting")
});
$('input').change(function (e) {
alert("fire");
});
Edit: For whatever reason, a change event is invoked when the input button is clicked. (thanks Anthony)
The way to fix this is simply don't select the submit button.
You can try
$('input:text')
To select only text fields.
Or you can do
$('input:not(:submit)')
To select all input elements except the submit button(s).
Read about selectors here
Edit: Using <button> instead won't work. It still counts as an input field, but it's value is separate from the text displayed on the button.
$('input').change(function(e){ alert("fire") }); applies that event to ALL input elements, including <input type="submit".../>. If you really want EVERY SINGLE text input element to have a change event, you want ``$('input[type=text]').change(function(e){ alert("fire") });` Otherwise, it might be best to use an id or class.
#Mark,
You are spot on and I'd edit you if I could to help out. Maybe someday soon...
#ajowi,
Submit buttons are inputs. At least most of them are:
<input type="submit" />
So Mark,it's not that they are doing anything with the button text, it's that the input, which is a button, is being changed by act of clicking on it.
So his solutions were great. Go with
$("input:text").change

Categories