Validate single textbox as either email or phone number

Is it possible to add combination of Phone and Email I’m single textbox. Enter 10 digit phone number based on html pattern else email id.

Your question is a little confused.

Do you want both phone and email as you say in the title, or one or the other as above?

Since textboxes are HTML, I have moved this to the HTML forum

No , I mean is it possible to add two feature in same textbox.
Like , user enter mobile number else email in single textbox.

This link might help you what I want to saying you…

It looks like you have answered your own question then.

Yes using input type="text" you can.(As given in the link provided by you)

Not enough…What about specific alert ?

The example you linked to shows an alert if the format doesn’t match. If that is not what you want, then you’ll need to explain the issue more clearly.

@shivkumar Can you be specific what alert?

<input type="text" name="emailphone" placeholder="email or phone" required>

See if the above helps you.

We want make same but the alert not show in div or popup or css box when error show.

Also show error when click submit not before.

This is problem

This is all a basic html .

REQUIRED JS and Css to make function and look

Then you can do some bootstrap jquery validations, which will help you show error on submit(if there’s any),

Ex: for email field

email: {
                validators: {
                    notEmpty: {
                        message: 'Please enter your Email Address'
                    },
                    emailAddress: {
                        message: 'Please enter a valid Email Address'
                    }
                }
            }

I’m sorry, but I don’t understand that. Where do you want the error message to be displayed?

That seems to be the behaviour of the code you have posted.

If I’m interpreting the question correctly, I believe that the error message is only supposed to appear when the submit button is clicked, and not as the input box is being completed, which is what I’m seeing happen now.

No matter…Any place…

Why is was nit working

That’s weird, because I’m not seeing that behaviour.

I can enter as many digits as I want, but the alert will only display after I click “Submit”.

Once triggered, it then stays until the box is edited to the correct format.

Then again, I don’t understand what your question is. What help are you asking for in displaying the message? What is wrong with the way it displays in your example?

Yeah, I think I was modifying an existing (good) entry I’d clicked submit on. When I backspaced on it, as the input box doesn’t clear on submission, it popped up the error message. I should have refreshed the page first.

Why not set up your own JSFiddle and show us what you have tried? No one can answer that question without seeing your code.

input type=“text” patter=“phone/email”