I have one text box for entering the serial number code. I need to install this code showing a warning if someone is using spase. this means that space is not allowed and minus is allowed for a separate code. Do you have an idea to solve this problem? can i use jquery validation?
the correct typing: 135x0001-135x0100
To prevent a space in the input element, you can do this with jQuery:
Example: http://jsfiddle.net/AQxhT/
$('input').keypress(function( e ) { if(e.which === 32) return false; });
.
$('input').keypress(function( e ) { if(!/[0-9a-zA-Z-]/.test(String.fromCharCode(e.which))) return false; });
Short and clear NOT jQuery dependent
function nospaces(t){ if(t.value.match(/\s/g)){ t.value=t.value.replace(/\s/g,''); } }
HTML
<input type="text" name ="textbox" id="textbox" onkeyup="nospaces(this)">
$('.noSpace').keyup(function() { this.value = this.value.replace(/\s/g,''); }); <input type="text" name ="textbox" class="noSpace" />
Source: https://habr.com/ru/post/1762771/More articles:Emacs-like Ctrl + Up / Down text navigation in Visual Studio 2010? - visual-studioDrupal module for displaying data in the form of a table - drupalCategorical Feature - libsvmWhat do I need to do to use the System.Windows.Forms.WebBrowser control in the WCF service? - c #How to get value in html control during postback in asp.net - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1762772/ab-test-with-google-web-optimizer-what-cookie-tells-me-visitor-got-a-or-b&usg=ALkJrhgrn65F9SqN62jU-4NJxSKc3X_G7wDynamically compiling and running shaders from a file in XNA - compiler-constructionHow can I find out which Hudson user is running under - hudsonHLSL: forced compilation of case-sensitive termination - xnaHow to control the flow of activity - the "Back" or "Home" button - androidAll Articles