How to check a comma in a text box. That is, if a comma is present, the code should warn,
<input type="text" id="name"/>
Thank..
You can do the following:
if ($('#name').val().indexOf(',') !== -1) { alert('There was a comma'); }
As you did not specify, you can put this code in an event blur, etc.
blur
$("#name").blur(function() { // or keyup, keydown, keypress, whatever you need if(this.value.indexOf(",") !== -1) { alert('got a comma'); } });
jQuery ( ). test().
test()
if( /\,/.test( $('#name').val() ) ) { alert('found a comma'); }
test() true false.
no-jQuery;)
if (document.getElementById("name").value.indexOf(",") !== -1) { .... }
Source: https://habr.com/ru/post/1745634/More articles:How to handle the error when using DataGridView controls and Access database queries? - c #How to find the most complex convex polygon spanning many points? - mathThe thread is writing my GUI - multithreadinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1745632/reading-and-writing-dates-to-the-registry-for-trial-version-purposes&usg=ALkJrhgnBq06vZT7dgijJUJ-5RjRrVBTaQΠ³ΡΡΠΏΠΏΠΈΡΠΎΠ²ΠΊΠ° ΠΈ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠ°Ρ ΠΈΠΌΠΏΠ»ΠΈΠΊΠ°ΡΠΈΡ Π² ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ - latexAbout the curse of dimension - databaseThe best way to check for NULL in a MySql query is mysqlReplace CR / LF in the text file only after a specific column - regexMark text in HTML - htmlphp preg_replace, I need to replace everything after the point (for example, 340.38888> I need to clear 340) - phpAll Articles