Frage

My question is simple:

How do I make the use of JavaScript regex to detect whether a #hashtag is being entered in the input element? I have a function to convert the hashtag into a clickable link but it's PHP. I want a similar function but in jQuery the reason is that if a hashtag is entered then I can send a value to the PHP processor form.

Sorry there is no code as I dont know much about JavaScript regex, also, I could not find any good tutorials.

War es hilfreich?

Lösung

You are looking for this: (#\w*)

function hasNonStandard(inputElem) { 
    return /[#\w*]/.test(inputElem.value);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top