Home Forums Porto Admin Template errorClass and Focus

This topic contains 5 replies, has 2 voices, and was last updated by  Support 6 months, 1 week ago. This post has been viewed 367 times

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10025073

    flexcf
    Participant

    1)How do you clear the errorClass on the datepicker when required?
    2) How to give focus via jquery? Tried .focus(), does not work

    Form is in modal!

    Thanks



    Template Version: DatePicker
    #10025083

    Support
    Keymaster

    Hello,

    1) Sorry, I don’t understand the question.

    2) $( "#theInputID" ).focus();

    Best Regards,

    Jonas


    #10025084

    flexcf
    Participant

    Jonas,

    The focus did not work.

    1) How do you clear the errorClass(red outline) on <input>?

    Thanks!


    #10025089

    Support
    Keymaster

    Hello,

    1) Here’s a working test:

    HTML:

    <input id="theInputID" type="text" class="form-control" />
    
    <button id="setFocus" class="btn btn-default">Set Focus</button>

    JS:

    $('#setFocus').on('click', function() {
    	$( '#theInputID' ).focus();
    });

    2) $( "#theInputID" ).removeClass('error');


    • This reply was modified 6 months, 2 weeks ago by  Support.
    #10025093

    flexcf
    Participant

    Jonas,

    When a required field is empty, bootstrap puts a red outline on the input field. How do you remove this in jquery? What don’t you understand about this question??


    #10025100

    Support
    Keymaster

    Hello,

    – If you are using jQuery validator:

    $( "#theInputID" ).removeClass('error');

    – If you are using Bootstrap Validation method: ( https://getbootstrap.com/docs/4.0/components/forms/#validation ) – You will see it uses css :invalid to add that border, so to avoid that you can’t just remove a class from the input, you need to remove the class from the parent form:

    $( "#theInputID" ).parents('form').removeClass('was-validated');

Viewing 6 posts - 1 through 6 (of 6 total)