android-edittext-validator icon indicating copy to clipboard operation
android-edittext-validator copied to clipboard

Error string/exclamation mark not showing on validation fail

Open asknask opened this issue 7 years ago • 9 comments

I have the FormEditText wrapped in the TextInputLayout class if that matters.

Whenever I test the validation, the error or the exclamation mark don't show. I have to manually focus the culprit field to get the error string shown.

This causes a lot of issues as the user doesn't know what the problem is.

Here's the xml:

<android.support.design.widget.TextInputLayout
                android:id="@+id/til_tradingName"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:hint="@string/trading_name">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/tradingName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapWords"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

asknask avatar Sep 30 '16 12:09 asknask

That seems strange. Which version of the lib are you usign?

vekexasia avatar Sep 30 '16 16:09 vekexasia

1.3.3.

It is indeed strange. Shall I share my entire xml?

Maybe it has something to do with the fact that I have 4 columns of FormEditTexts on one horizontal layout. If I keep pressing enter to go to the next field, some fields get skipped.

On Sep 30, 2016 9:03 PM, "Andrea Baccega" [email protected] wrote:

That seems strange. Which version of the lib are you usign?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vekexasia/android-edittext-validator/issues/49#issuecomment-250784025, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaIfp8quhl2YXJAU0lvq1kUvdggzWbYks5qvTLWgaJpZM4KLBCy .

asknask avatar Sep 30 '16 16:09 asknask

It is probably due to your layout. Did you try to place it out the column layout?

Il 30 set 2016 6:32 PM, "Asim Shahzad" [email protected] ha scritto:

1.3.3.

It is indeed strange. Shall I share my entire xml?

Maybe it has something to do with the fact that I have 4 columns of FormEditTexts on one horizontal layout. If I keep pressing enter to go to the next field, some fields get skipped.

On Sep 30, 2016 9:03 PM, "Andrea Baccega" [email protected] wrote:

That seems strange. Which version of the lib are you usign?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/vekexasia/android-edittext-validator/ issues/49#issuecomment-250784025>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AMaIfp8quhl2YXJAU0lvq1kUvdggzWbYks5qvTLWgaJpZM4KLBCy> .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vekexasia/android-edittext-validator/issues/49#issuecomment-250790986, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMPS2pZWoig0CBMAE0ZnYWAa_va4Egaks5qvTmvgaJpZM4KLBCy .

vekexasia avatar Sep 30 '16 16:09 vekexasia

On Fri, Sep 30, 2016 at 9:51 PM, Andrea Baccega [email protected] wrote:

It is probably due to your layout. Did you try to place it out the column layout?

Il 30 set 2016 6:32 PM, "Asim Shahzad" [email protected] ha scritto:

1.3.3.

It is indeed strange. Shall I share my entire xml?

Maybe it has something to do with the fact that I have 4 columns of FormEditTexts on one horizontal layout. If I keep pressing enter to go to the next field, some fields get skipped.

On Sep 30, 2016 9:03 PM, "Andrea Baccega" [email protected] wrote:

That seems strange. Which version of the lib are you usign?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/vekexasia/android-edittext-validator/ issues/49#issuecomment-250784025>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AMaIfp8quhl2YXJAU0lvq1kUvdggzWbYks5qvTLWgaJpZM4KLBCy> .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/vekexasia/android-edittext-validator/ issues/49#issuecomment-250790986>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AAMPS2pZWoig0CBMAE0ZnYWAa_va4Egaks5qvTmvgaJpZM4KLBCy> .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vekexasia/android-edittext-validator/issues/49#issuecomment-250795381, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaIfjBjmeJ0qduK8mOTAMvyy1rREDs9ks5qvT4VgaJpZM4KLBCy .

Regards, Asim Shahzad Software Developer Nettech Limited

asknask avatar Sep 30 '16 16:09 asknask

 <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SalesForm1">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="2">

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_tradingName"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:hint="@string/trading_name">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/tradingName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapWords"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_address"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="@string/address">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/address"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPostalAddress"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:orientation="horizontal">

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_postcode"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="5dp"
                    android:hint="@string/postcode">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/postcode"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textCapCharacters"
                        app:testType="nocheck"/>

                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_phone"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="5dp"
                    android:hint="@string/phone">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/phone"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="phone"
                        app:testType="phone"/>

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_fax"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="5dp"
                    android:hint="@string/fax">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/fax"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="phone"
                        app:testType="phone"/>

                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_mobile"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="5dp"
                    android:hint="@string/mobile">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/mobile"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="phone"
                        app:testType="phone"/>

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_companyName"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="@string/company_name">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/companyName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapWords"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_directorName"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="@string/director_full_name">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/directorName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName"
                    app:testType="personFullName"/>

            </android.support.design.widget.TextInputLayout>

        </LinearLayout>
    </ScrollView>

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="@color/dividerColor"/>

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_regNo"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:hint="@string/company_reg_no">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/regNo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapCharacters"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_clientClassification"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="@string/client_classification">

                <com.andreabaccega.widget.FormEditText
                    android:id="@+id/clientClassification"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapWords"
                    app:testType="nocheck"/>

            </android.support.design.widget.TextInputLayout>

            <CheckBox
                android:id="@+id/checkboxAppointment"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="@string/view_by_appointment_only"/>

            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:orientation="horizontal"
                android:gravity="center">

                <CheckBox
                    android:id="@+id/checkboxSMS"
                    android:layout_width="80dp"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="2dp"
                    android:layout_marginEnd="4dp"
                    android:text="@string/sms"
                    android:layout_gravity="bottom"/>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_messageCell"
                    android:layout_width="216dp"
                    android:layout_height="wrap_content"
                    android:hint="@string/telephone"
                    android:visibility="gone">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/messageCell"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="phone"
                        app:testType="phone"/>

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:orientation="horizontal">

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_maxcars"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="5dp"
                    android:hint="@string/maximum_cars">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/maxcars"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        app:testType="numeric"/>

                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_carInitials"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="5dp"
                    android:hint="@string/initials">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/carInitials"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textCapCharacters"
                        app:testType="nocheck"/>

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:orientation="horizontal">

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_dealerships"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="5dp"
                    android:hint="@string/no_of_dealerships">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/dealerships"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        app:testType="numeric"/>

                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/til_dealershipInitials"
                    android:layout_width="145dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="5dp"
                    android:hint="@string/initials">

                    <com.andreabaccega.widget.FormEditText
                        android:id="@+id/dealershipInitials"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textCapCharacters"
                        app:testType="nocheck"/>

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

<com.dmitrymalkovich.android.ProgressFloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_gravity="bottom|end"
    android:clickable="true">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/login_24dp"
        app:fabSize="normal"/>

    <ProgressBar
        android:id="@+id/submit_fab_progress"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"/>

</com.dmitrymalkovich.android.ProgressFloatingActionButton>
`

asknask avatar Sep 30 '16 16:09 asknask

Can this be fixed?

EDIT: A temporary workaround for anyone facing the issue. Modify your for loop for validation. Make it something like this. As soon as the problematic field has focus, the error shows up.

for(FormEditText field : fields)
    {
        if(field.testValidity())
        {
            validation = true;
        }
        else
        {
            validation = false;
            field.requestFocus();
            break;
        }
    }

asknask avatar Oct 03 '16 10:10 asknask

The same problem. +1

dimparf avatar Oct 26 '16 00:10 dimparf

i have same problem i use compile 'com.android.support:design:25.0.1' i see code ,so i find DefaultEditTextValidator--> @Override public void showUIError() { if (mValidator.hasErrorMessage()) { try { TextInputLayout parent = (TextInputLayout) editText.getParent(); parent.setErrorEnabled(true); parent.setError(mValidator.getErrorMessage()); } catch (Throwable e) { editText.setError(mValidator.getErrorMessage()); } } }

should be
TextInputLayout parent = (TextInputLayout) editText.getParentForAccessibility();

diandian71 avatar Dec 12 '16 02:12 diandian71

Can you test It and submit a pull request?

On Dec 12, 2016 3:04 AM, "diandian71" [email protected] wrote:

i have same problem i use compile 'com.android.support:design:25.0.1' i see code ,so i find DefaultEditTextValidator--> @Override https://github.com/Override public void showUIError() { if (mValidator.hasErrorMessage()) { try { TextInputLayout parent = (TextInputLayout) editText.getParent(); parent.setErrorEnabled(true); parent.setError(mValidator.getErrorMessage()); } catch (Throwable e) { editText.setError(mValidator.getErrorMessage()); } } }

should be TextInputLayout parent = (TextInputLayout) editText. getParentForAccessibility();

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vekexasia/android-edittext-validator/issues/49#issuecomment-266327714, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMPSzjTSht4Dyb0Rmh2RLUk3oVSoy2mks5rHKungaJpZM4KLBCy .

vekexasia avatar Dec 12 '16 08:12 vekexasia