Ignore Hyphen

Hi Team,

I have a textfield which should not accept hyphen in it.
123-5 or 123-10. When i click the submit button should alert the user that the particular field contains hyphen. Kindly provide a sample code.

If textfield.contains("-") then display user it have hyphens

Apologiesi forgot to mention that i wanted in javascript code.

Hi @Balan

I hope the below code will help you

var str = document.getElementById("txtBox").value;
    alert("Contains hyphen");