lundi 25 février 2019

Gravity Forms - Conditional merge tags - MULTIPLE Values in a single tag

I am using the Conditional Merge Tags shortcode in the form confirmation as found here: https://gravitywiz.com/gravity-forms-conditional-shortcode/

I've got a number field on the form where I ask people to input their age.

On the confirmation message, I'm using the merge tags to display a custom message based on the age input.

So for people who are younger than 18, I use shortcode with a message:

[gravityforms action="conditional" merge_tag="{my-field}" condition="less_than" value="18"]
You're too young.
[/gravityforms]

For people who are older than 55, I use shortcode with a message:

[gravityforms action="conditional" merge_tag="{my-field}" condition="greater_than" value="55"]
You're too old.
[/gravityforms]

Now I struggle to show the message to people who are between 18 - 55.

I'm trying to input multiple values from 18 to 55 with condition="is" like this:

[gravityforms action="conditional" merge_tag="{my-field}" condition="is" value="18, 19, 20, 21, ....... 54, 55"]
        You're the perfect age.
[/gravityforms]

But this doesn't work.

Is there any way I can use multiple values or specify something like is greater_than and less_than in the same single tag?

JOptionPane.showMessageDialog- Question-Easy Code

I have this code and always that I execute appears two messages. JOptionPane.showMessageDialog(null, "ERROR DE PENSION"); JOptionPane.showMessageDialog(null, "ERROR PROMEDIO");

I don't understand why. Because I put this messages only if I choose certain values. But even if I choose other values still keep going these 2 messages.

Please, help me understand why!!

    int pension;
    String categoria;
    Double promedio;
    Double descuento;

    categoria = txtTP.getText().toString();
    System.out.println("hola" +categoria);
    if (categoria.equalsIgnoreCase("A"))
        pension = 550;

    else
        if(categoria.equalsIgnoreCase("B"))
            pension = 500;

        else
            if(categoria.equalsIgnoreCase("C"))
                pension = 460;
            else
                if (categoria.equalsIgnoreCase("D"))
                pension = 400;
                else
                pension = 0;
                JOptionPane.showMessageDialog(null, "ERROR DE PENSION");

                System.out.println(pension);


    promedio = Double.parseDouble(txtP.getText());
    if (promedio>0 && promedio<14)
        descuento=0.00;
    else if (promedio >=14 && promedio < 16)
        descuento = 0.1;
    else if (promedio >=16 && promedio <18 )
        descuento = 0.12;
    else if (promedio >=18 && promedio <=20)
        descuento = 0.15;
    else
        descuento = 0.00;
        JOptionPane.showMessageDialog(null, "ERROR PROMEDIO");



textM.setText("Tienes" +descuento +"% de rebaja");

javascript multiplication table order

I have the followign school project:

  • You enter a number into a prompt
  • Highlights every occurance of numbers in interval [1; 100] that are the multiplicator of the inputted number.

Issue is, whenever I input a number dividable by /5 it ruins the table formatting with the extra <br/>

<html>
<body>
    <script>

        var y = prompt("enter a number between 1 -100 ")
            if( y<=100 && y>=1 ){
                for (i = 1 ; i<=100 ; i++){
                var idk = i + " "
                    if (i%y!=0){
                    document.write(idk)
                    }
                    if(i%10==0 ){
                        document.write("</br>" )
                        console.log(i)
                    }

                     if(i%y==0){

                        document.write(idk.fontcolor("red"))
                    }
                }





            }
            else {
            document.write("your number isnt good")
            }

    </script>
</body>

this is my code can someone help me fix it

ShowMessageDialog - Components

I thing my question is very simple for you. I am recently starting with programming. I woudl like to know exactly what it's doing the null of the showMesageDialog(null,"string").

I always see that people set null, but I don't know exactly why is the reason to put null.

I put an example.

Hope you can help me.

"JOptionPane.showMessageDialog(null, "ERROR DE PENSION");"

//1. Definicion de variables

    int pension;
    String categoria;
    Double Promedio;
    Double Descuento;

    categoria = txtTP.getText().toString();
    System.out.println("hola" +categoria);
    if (categoria.equalsIgnoreCase("A"))
        pension = 550;

    else
        if(categoria.equalsIgnoreCase("B"))
            pension = 500;

        else
            if(categoria.equalsIgnoreCase("C"))
                pension = 460;
            else
                if (categoria.equalsIgnoreCase("D"))
                pension = 400;
                else
                pension = 0;
                JOptionPane.showMessageDialog(null, "ERROR DE PENSION");

If else condition - Javascript

I will use three variables for this,

I have requirement to do something like:

1. if(A found in B and not C){
    //do something
}
2. if(A found in C and not B){
    //do something
}
3. if(A is found in both (B, C) or in none (B,C)){
    //do something
}

How do I proceed the best way with logic and syntax (javascript)?

How to make it simpler and works?

def Choose():

Options = input()

if Options == 1:
    Penarikan_Tunai()
elif Options == 2:
    Setor_Tunai()
elif Options == 3:
    Transfer()
elif Options == 4:
    Informasi_Saldo()
elif Options == 5:
    Pembayaran_Lainnya()
elif Options == 6:
    Ganti_Pin()
elif Options == 'X' or Options == 'x':
    Thanks()
else:
    print("Pilihannya hanya 1 - 6.\n")
    Choose()

I'm to the point, How to make it simpler and works? That's all. But the website keep makes me to write more words, and warn me with "It looks like your post is mostly code; please add some more details."

Progress bar, mvc 5, controlador y validacion

me encuentro algo estancado sobre una validacion tengo la siguiente validacion: namespace Oronet.Web.Areas.Enrolamiento.Models { public class Validacion { public ValPass Validacioncontrasena(ValPass row) {

        try
       {
            row.Code = "danger";
            var mayuscula = false;
            var minuscula = false;
            var numero = false;
            var caracter_raro = false;
            Regex regex1 = new Regex(@"^(?=.*userid)\S{3,16}$");
            Regex regex2 = new Regex(row.Usuario);
            int i = 0;
            int a1 = 0;              
            // Regex regex = new Regex(@"^(?=\S*?[A-Z])(?=\S*?[a-z])(?=\S*?[0-9])(?=\S*?[!-/:-@[-`])\S{3,16}$");// valida ingreso de numeros, letras (?!.*(.)\1)
            if (row != null && row.Usuario != "" && row.Pass != "")
            {
                if (regex1.IsMatch(row.Pass) == false || regex2.IsMatch(row.Pass) == false)
                {

                    for (int j = 0; j < row.Pass.Length; j++) {
                    var c0a = row.Pass[j];
                    var c1a = Encoding.ASCII.GetBytes(c0a.ToString())[0];
                    if (row.Pass.Length >= 0 && row.Pass.Length <= 3)
                    {
                        if (c1a >= 97 && c1a <= 122)
                        {
                            // minuscula
                            minuscula = true;
                        }
                        else if (c1a >= 48 && c1a <= 57)
                        {
                            // numeros
                            numero = true;
                        }
                        else if (c1a >= 65 && c1a <= 90)
                        {
                            //letras mayusculas
                            mayuscula = true;
                        }
                        else
                        {
                            // caracteres especiales
                            caracter_raro = true;
                        }                            
                    }
                    else if (row.Pass.Length >= 4 && row.Pass.Length <= 7)
                    {                            
                            if (c1a >= 97 && c1a <= 122)
                            {
                                // minuscula
                                minuscula = true;
                            }
                            else if (c1a >= 48 && c1a <= 57)
                            {
                                //numeros
                                numero = true;
                            }
                            else if (c1a >= 65 && c1a <= 90)
                            {
                                //letras mayusculas
                                mayuscula = true;
                            }
                            else
                            {
                                // caracteres especiales
                                caracter_raro = true;
                            }    
                    }
                    else if (row.Pass.Length >= 8 && row.Pass.Length <= 16)
                    {
                             if (c1a >= 97 && c1a <= 122)
                            {
                                minuscula = true;

                            }
                            else if (c1a >= 48 && c1a <= 57)
                            {
                                numero = true;
                            }
                            else if (c1a >= 65 && c1a <= 90)
                            {
                                mayuscula = true;
                            }
                            else
                            {
                                // caracteres especiales
                                caracter_raro = true;
                            }                                                        
                    }
                }


                    for (i = 0; i < row.Pass.Length - 1; i++)
                    {
                        var c0 = row.Pass[i];
                        var ca = row.Pass[i + 1];
                        var c1 = Encoding.ASCII.GetBytes(c0.ToString())[0];
                        var c2 = c1 + 1;
                        var c3 = (char)c2;
                        var mayc3 = char.ToUpper(c3);
                        var minc3 = char.ToLower(c3);
                        var mayca = char.ToUpper(ca);
                        var minca = char.ToLower(ca);
                        if (mayc3 == ca || minc3 == ca)
                        {
                            row.Mensaje = "No se puede ingresar caracter consecutivo";
                            row.Code = "danger";
                            a1 = 1;
                            mayuscula = false;
                            minuscula = false;
                            numero = false;
                            caracter_raro = false;
                            break;
                        }

                        if (c0 == mayca || c0 == minca)
                        {
                            row.Mensaje = "No se puede ingresar caracter repetidos";
                            row.Code = "danger";
                            a1 = 1;
                            mayuscula = false;
                            minuscula = false;
                            numero = false;
                            caracter_raro = false;
                            break;
                        }
                        else if (a1 != 1)
                        {
                            if (row.Pass.Length >= 1 && row.Pass.Length <= 3)
                            {
                                if (mayuscula == true && minuscula == true && numero == true)
                                {
                                    row.Code = "danger";
                                }
                                else if (mayuscula == true && minuscula == true && caracter_raro == true)
                                {
                                    row.Code = "danger";
                                }
                                else if (mayuscula == true && numero == true && caracter_raro == true)
                                {
                                    row.Code = "danger";
                                }
                                else
                                {
                                    row.Code = "danger";
                                }
                            }
                            else if (row.Pass.Length >= 4 && row.Pass.Length <= 7)
                            {
                                if (regex1.IsMatch(row.Pass) != true || regex2.IsMatch(row.Pass) != true)
                                {
                                    if (mayuscula == true && minuscula == true && numero == true && caracter_raro == true)
                                    {
                                        row.Code = "warning";
                                    }                                       
                                    else
                                    {
                                        row.Code = "danger";
                                    }
                                }
                                else
                                {
                                    row.Mensaje = "no se puede ingresar el usuario";
                                    row.Code = "danger";
                                }
                            }
                            else if (row.Pass.Length >= 8 && row.Pass.Length <= 16)
                            {

                                if (mayuscula == true && minuscula == true && numero == true && caracter_raro == true)
                                {
                                    row.Code = "success";
                                }                                   
                                else
                                {
                                    row.Code = "danger";
                                }                                   
                            }
                            else
                            {
                                row.Mensaje = "contraseña invalida";
                                row.Code = "danger";
                            }
                        }

                    }
            }
            else
            {                    
                row.Mensaje = "contraseña invalida";
                row.Code = "danger";
            }

        }
                else {
                    row.Mensaje = "no se puede ingresar el usuario";
                    row.Code = "danger";
                }               
            if (row.Pass == row.confipass)
            {
                row.a1 = 1;                   
            }               
            row.Usuario = "";
            row.Pass = "";
            row.confipass = "";
        }
        catch (Exception ex)
        {
            row.Error = false;
            row.Mensaje = ex.Message;
        }




        return row;
    }
}

}

su clase para guardar estos datos luce asi: namespace Oronet.Web.Areas.Enrolamiento.Models { public class ValPass { public string Pass { set; get; } public string Usuario { set; get; } public string Code { set; get; } public string Mensaje { set; get; } public bool Error { set; get; } public string confipass { set; get; } public int a1 { set; get; } } }

mi problema es con esta linea:

if (regex1.IsMatch(row.Pass) == false || regex2.IsMatch(row.Pass) == false) se supone que al declarar estos regex1 y regex2 de esta forma

Regex regex1 = new Regex(@"^(?=.*userid)\S{3,16}$"); le digo que en el campo contraseña si existe la palabra userid

Regex regex2 = new Regex(row.Usuario); y aqui lo mismo busco que coincida es decir, que el nombre de usuario no este en el campo contraseña pero esta linea no funciona, de existir las dos coincidencias que sea verdad entra por aqui

       else
            {                    
                row.Mensaje = "contraseña invalida";
                row.Code = "danger";
            }

lo que trato de hacer es que al crear nuevo usuario si el usuario digita en el campo contraseña userid o elnombre de usuario que escoga, asi automaticamente, marque rojo