Check All input text fields in form empty or not on Submission, Ignore if at least one text field is filled
Date : March 29 2020, 07:55 AM
it fixes the issue Here is the situation , DEMO$('#dataFieldMapping').submit(function (e) {
if (!$(this).find('input:text').filter(function () {
return $.trim(this.value) != ""
}).length) {
alert("Empty!");
e.preventDefault();
}
});
|
Woocommerce custom fields won't update when I leave them empty and still displays empty fields
Date : March 29 2020, 07:55 AM
hop of those help? I added a custom field to a single product page for woocommerce in order to show ISBN number for the books I sell. I found a nice guide and managed to add everything as I want. However when I empty the custom field for ISBN it won't go empty on the site. , Your save function should be like function woo_add_custom_general_fields_save( $post_id ){
// Customer text ISBN Field
$woocommerce_text_field = $_POST['_ISBN_field'];
if( !empty( $woocommerce_text_field ) )
update_post_meta( $post_id, '_ISBN_field', esc_attr( $woocommerce_text_field ) );
else
update_post_meta( $post_id, '_ISBN_field', '' );
}
|
jQuery - why are the text fields getting empty?
Date : March 29 2020, 07:55 AM
I wish this helpful for you Solution found. I doubled the whole function! It's certainly not the best way to solve that problem and not very clean, but it works... First function is used for change() event, the second for ready(). In the second, I didn't double the html return code that is not needed in my code. $(document).ready(function(){
$(".select_client").change(function() {
var e = document.getElementById("InputClient");
var id_client = e.options[e.selectedIndex].value;
if (id_client != "free")
{
if (id_client)
{
$.ajax({
type: "POST",
url: "http://satch/suivi-hbl/misc/scripts/get_client.pl", // URL of the Perl script
// send id_client and name as parameters to the Perl script
data: "id_client_facture=" + id_client,
// script call was *not* successful
error: function() {
alert("script call was not successful");
},
// script call was successful
// perl_data should contain the string returned by the Perl script
success: function(perl_data){
$('div#contactCatcher').html(perl_data);
}
});
}
else {
$('div#contactCatcher').html("Veuillez s\é\;lectionner un client.");
// $('div#contactCatcher').addClass("error");
}
$('div#contactCatcher').fadeIn();
return false;
}
else
{
$('div#contactCatcher').html("<div class=\"form-group\"><label for=\"ContactNom\">Nom</label><input type=\"text\" class=\"form-control\" name=\"contact_nom\" id=\"ContactNom\"></div><div class=\"form-group\"><label for=\"ContactAdresse\">Adresse</label><input type=\"text\" class=\"form-control\" name=\"contact_adresse\" id=\"ContactAdresse\"></div><div class=\"row\"><div class=\"form-group col-xs-6\"><label for=\"ContactCodePostal\">Code postal</label><input type=\"text\" class=\"form-control\" name=\"contact_code_postal\" id=\"ContactCodePostal\"></div><div class=\"form-group col-xs-6\"><label for=\"ContactVille\">Ville</label><input type=\"text\" class=\"form-control\" name=\"contact_ville\" id=\"ContactVille\"></div></div><div class=\"form-group\"><label for=\"ContactPays\">Pays</label><input type=\"text\" class=\"form-control\" name=\"contact_pays\" id=\"ContactPays\"></div>");
}
});
}).change();
$(document).ready(function(){
$(".select_client").ready(function() {
var e = document.getElementById("InputClient");
var id_client = e.options[e.selectedIndex].value;
if (id_client)
{
$.ajax({
type: "POST",
url: "http://satch/suivi-hbl/misc/scripts/get_client.pl", // URL of the Perl script
// send id_client and name as parameters to the Perl script
data: "id_client_facture=" + id_client,
// script call was *not* successful
error: function() {
alert("script call was not successful");
},
// script call was successful
// perl_data should contain the string returned by the Perl script
success: function(perl_data){
$('div#contactCatcher').html(perl_data);
}
});
}
});
});
|
App crashes when click with empty text fields
Date : March 29 2020, 07:55 AM
This might help you I have write a method for register users for backendless. With filled all text fields I can register users. My problem is when when I click button with empty text fields app getting crash, but I wrote a if statement for check empty text fields and show a toast. , you should check with if(TextUtils.isEmpty(email.getText()))
if (email.getText() == null)
|
How to count text fields that are not empty with JQuery?
Date : March 29 2020, 07:55 AM
Does that help There's no selector to retrieve empty input elements, so the only way to achieve what you require is through a loop. You can use an implicit loop, though, by using filter() instead of each(), like this: var cnt = $('input[name="items"]').filter(function() {
return this.value.trim() == '';
}).length;
|