Re: text entry validation




void
on_bt_validate_clicked                 (GtkButton       *button,
                                        gpointer         user_data)
{

if (........dont know how to check)......)
{


}
else/*******check if not correct then display dialog box*****/

GtkWidget *dialog1;
dialog1 = create_dialog1 ();
gtk_widget_show (dialog1);

}

Maybe something like this will help:

void
on_bt_validate_clicked                 (GtkButton       *button,
                                       GtkEntry *entry)
{
        gboolean hasdigit = FALSE;
        const gchar * string = gtk_entry_get_text (entry);
        gint length = strlen (string);
        gint i = 0;
        
        while ((i < length) && (!hasdigit))
        {
                hasdigit = g_ascii_isdigit (string [i]);
                i++;
        }
        
        if (hasdigit)
                /* Show dialog */
        else
                /* Do something else */
}

The function g_ascii_isdigit checks wheter a character is an ASCII digit (0-9).



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]