Keeping input value for validation in Vue JS - forms

Making login function with string validation with VueJS
Here is my code: Link
Problem occurs in this follow,
both input keep with empty and click Login button
error msg Enter your username and Enter your password appear
enter something in one of these input
ex) entering xxxx in password area
click Login button
Problem happens
value of password input area disappears
I'd like to keep value in input box every time Login button clicked till both input value are correct.
How can I fix it?
Form validation function are written in Login.vue

Register (add) value prop in Form.vue component:
props: {
// ...your registered props
// add below
value: {
type: String,
default: "",
},
},
Why?
Because right now it is not reactive. So when parent changes value child component does not react.

Related

Not able to create Calabash step definition for scenario

I'm new to Calabash and trying to create Steps definition for below the feature file with respective scenarios (QA looks like a possible duplicate but no answer found in SOF) How to generate the step definition using UIAutomator viewer tool. error screenshot attached for ref Any help on this issue would be appreciated.
Feature: Valid Login
Scenario: Login with valid mobile number
When I see "Login/Signup" screen
And I enter "72046606**" in "etMobilNumber" text field
And I click on "Login/Signup" button
And I enter "WebDriver12" in "etPassword" text field
And I click on "Login" button
And I wait
Then I see "Enter mPIN" screen
Scenario: Login with valid mPIN
When I see "Enter mPIN" screen
And I click on "2" button
And I click on "3" button
And I click on "6" button
And I click on "9" button
And I wait
Then I see "J****" text
Scenario: Launch Money Transfer screen
When I see "J*****" screen
And I click on "MoneyTransfer" button
And I click on "Send Money" text
And I wait
Then I see "Send Money" text
Feature file:
Feature: Login
Scenario: I should login via valid credentials
When I enter mobile number "7204660611" into mobile number input field with "ID"
Then I see "Login/Signup" button as enable
And I tap "Login/Signup" button
Then I wait 60 seconds
Then I see "Password" field
And I enter Password "WebDriver12" input Password input field with "ID"
Then I tap "Login" button
Then I should get new page
Step Definition:
require 'calabash-android/calabash_steps'
When(/^I enter mobile number "([^"]*)" into mobile number input field with "([^"]*)"$/) do |mobileNumber, etMobileNumber|
enter_text("* marked:'etMobileNumber'","***34*****")
end
Then(/^I see "([^"]*)" button as enable$/) do |arg1|
if query("* marked:'btnSignin'",:enabled).first.eql?true
else
raise "FAILED!!! Invalid Mobile number"
end
end
Then(/^I tap "([^"]*)" button$/) do |arg1|
touch("* marked:'btnSignin'")
end
Then(/^I wait (\d+) seconds$/) do |arg1|
wait_for_element_exists("* marked:'etPassword'")
end
Then(/^I see "([^"]*)" field$/) do |arg1|
if query("* marked:'etPassword'",:enabled).first.eql?true
else
fail "Failed!! Password field not present"
end
end
Then(/^I enter Password "([^"]*)" input Password input field with "([^"]*)"$/) do |arg1, arg2|
enter_text("* marked:'etPassword'","WebD*****")
end
Then(/^I should get new page$/) do
wait_for_element_exists("* marked:'Enter mPIN'")
end

How to know if jQuery validator already exists for a form?

Imagine I have an unordered list with 2 cols, col 1 is the name of a file and col 2 is a pencil icon which has tooltip enabled. When the user clicks on this pencil icon, it opens a tooltip which contains a form. In this form the user will enter a new file and the value will be validated.
When the tooltip is shown, I attach jQuery validator to the form inside the tooltip. The problem is that each time the tooltip is shown, a new validator is attached. I would like to only attach one validator to a form. How can I successfully check if validator already exists for a form?
var validator = forms.validate();
console.log(validator);
// always evaluate to true
if (validator) {
}
This doesn't seem to work. Does anyone have any ideas?
You can use the jQuery data to check if the validator exists on a form element like this:
var form = $('#myform');
if(form.data('validator')){
// validator exists
}
I realized that I could just check to see if a form has the class "novalidate" to determine if the form has a validator attached or not.
var forms = jQuery("form.edit");
if (forms.attr("novalidate")) {
return;
}

Validate a text field while typing input into a text box

I am trying to implement a sign-up form that asks users to input the desired login-id.
The user inputs the desired login-id into a text box.
I would like to perform validation on this text box to see if the desired login-id is available without having to submit the form.
The validation should start happening say after the 5th character is input into the text box.
You should validate the complete username typed in. This will reduce your client server interaction too thus giving you performance too.
You can use jQuery's ajax method. Which will call your server side code and you can check from there by querying the database and can send back the date to client side.
HTML:
<input type="text" id="username" onblur="checkUsername(this);"/>
Javascript:
function checkUsername(element){
$.ajax({
url: server_url,
data : element.value
}).done(function(data) { //json object returned from server
if(data.true){
//allowed
}else{
alert("select another username");
}
});
}
You can use the Client Side Validation module. This module does the validation and shows the error message before the submission of the form

Form submit button to email based on a fields value

I'm creating a PDF form with a submission button. I would like the form to email based on the value of another form in the field. I'm assuming I need to do an "IF...ELSE" statement, but keep getting a syntax error that I cannot figure out. I am completely java illiterate.
This can be done using multiple solutions, but you do need to program Javascript inside of the PDF. You can use if-else on-click of the email-button. Here you can check values entered inside of the PDF form:
if (this.getValue("somefield") == "left") { emailvalue = "toA#domain.com" } else { emailvalue = "toB#domain.com" }
But you could also set the value onBlur or onFocus of a certain field. Like with radio-buttons the onBlur is useful because you know the user clicked or focused on this field and so set the variable emailvalue to a certain value.

Zope form : adding a button to automatically fill some fields

under Plone4/Zope3, I have a form to add a new object.
I'd like to add a button after the first field, to do the following :
- the user enters the value for the first field
- he presses this new button
- and the server will try to guess the remaining field based on the first field and an external database.
- the user will then have to check if all fields are OK and then submit the form.
I am not a zope expert, and spent some time trying to figure out how to do this.
Is creating a subform a good idea ?
If not, I could add a new button to the form : I tried something like
#button.buttonAndHandler(_(u'Essai'))
def essai(self, action):
print "button essai"
but then I have the following issues :
- how to render the button after the first field and not at the bottom ?
- how to update the remaining fields without submitting the form ?
- how to keep the "add" and "cancel" button that disappeared when I added this essai button.
any hints ?
Thx
I suggest to use javascript to solve this. With jquery you can include an extra button directly behind your first field (http://api.jquery.com/after). In the button action ask a browser view for the search results in json (http://docs.python.org/library/json.html) an fill up the other form fields, like:
jq('my-button').click(function(event) {
event.preventDefault();
var first_field= jq('#first-field-id').val();
jq.getJSON('/##my-browser-view?value=' + value, function(result) {
jq('#other-field-id').val(result.val_for_other_field);
...
});
});