Small but boring issue:
We have an Form field inside an DojoX Grid (1.2). If the user changes the value inside this field, and is hitting the "Submit" Button without clicking somewhere else the new value is ignored.
Is there any way to "accept" all Values entered inside the field, when hitting submit? Or something like "onMouseOut" Accept value?
An colleague has found an solution:
grid.edit.apply();
before submit..
Related
I have a text field, dropdown, date picker, and etc. My form won't have a save button so I don't have any type of "submit". For text field, I want the onSubmit to trigger to happen when the user enters enter button. For dropdown and date picker, it would call onSubmit when a user picks a different value aka onChange. It seems like you need a button or something of type submit to trigger onSubmit but it's not like I can put two types per Field. Any ideas on how I can trigger submit per field without any clicking any buttons?
here is a sandbox where I tried to trigger onSubmit per field.
https://codesandbox.io/s/react-final-form-external-submit-button-forked-gz40r3
one of the parameters that is getting passed in the Form's render is a reference to "form". You can trigger form.submit() in onChange or pass it as a param to another function and call it within that function.
What I want
When I submit a form, this specific field must to turn empty if the value is invalid.
I have this function that validate the value and set it empty if necessary.
The problem
When I try to submit the form with an invalid value the function clears the field and it seems to work, but if I click again to submit the form the old value (that doesn't apears in the field anymore) kinda bypasses the validation and is inserted into the database.
The val('') is cleaning the field but somehow the value remains.
The code
Here is the code I am using:
if (response==true) {
$("#license").val('');
}
What I already tried
document.getElementById('license').value = "" // didn't work at all
$("#license").val(' '); // with one space but I lose the placeholder visualization, and I need it
Could anyone help me? Thanks!
I have a JSP registration form in my site. Also I have a text box with placeholder="opt" and id="ext" in my JSP registration page which is an optional field. On clicking submit button the value of placeholder is submitting to the database on leaving the optional field blank. But I want to clear the value of text box on leaving it blank. I've tried the below methods. But those methods are not working in my case.
document.getElementById("ext").value="";
document.getElementById("ext").placeholder="";
document.getElementById("ext").setAttribute("placeholder","");
I've also tried the same methods with jQuery. That also is not working.
Can anybody suggest a solution.
You can prevent the value of placeholder entering into DB b having a condition on servlet (business logic) i.e the page handling the DB operations.
Check on servlet like as below:
if(request.getParameter("<Parameter name Here>").equals("<Plaeholder value>"))
{
// set value of <Parameter name Here> nullhere
// Do insert option here
}
The solution will be valid untill you wil change the placeholder's value.
I have input field
<input type="text" name="vehicle_make[]" id="make1"/>
and i have help dropdown that updates this field if user choose to do so. I do it trough standard jquery code
$("#make1").val("value");
Problem is, since i use validate plugin to validate this field, if user click on validate before entering anything in that box, he will get notice that he needs to fill it, but then if he fills it trough dropdown, validate plugin will not detect it until user click on submit again.
I know i could call submit in function in which i process dropdown, but i think that it is not right solution, since i would need to check if validation is already done before doing that (since if it is not, it would start validation before i want it to start).
I also need to tie some other things to that field also, so i would like to know is there is a way in which i could write function so it always check if field is filled, even if user did not fill it directly.
Sorry if i didn't explain everything right, this is my first message here.
Try this
$("#make1").change(function(){
//do something there
});
I have found solution. First, i created js variable form_submitted, and added onclick event to submit button, to change value of variable form_submitted to yes. Then, i created function:
function update_validation(){
if(form_submitted == 'yes'){
$("#my_form").valid();
};
};
that i call when user do something that is not detected regularly with validate plugin. This function manually starts validation again, but only if it has been started before by clicking on submit.
I have a form that uses a servlet I don't have access to for validation. The powers that be want the field to be prefilled with a value "Enter promotion code" - unfortunately, since placeholder doesn't work with IE, the field is going through the validation process on submit for the default text.
Is there a way to clear the value on that field if the value equals the default text when the form is submitted? (jquery or javascript)
thanks!
You should toss this somewhere on load.
If you aren't using jQuery on the page yet, it'll look like this:
$(function() {
// when the submit button is pressed
$('#yourForm').submit(function() {
if($('#yourInputBox').val() == YOUR_DEFAULT_STRING)
$('#yourInputBox').val(''); // clear the value
return true; // submit the form
});
});
You haven't provided any code to work with, but conceptually you can hook the submit function for your form with javascript, check to see if the prefilled value is still in the form and clear it if so and then allow the submit to proceed.