I want to change all my form values to uppercase before the form is submitted.
So far I have this but it's not working.
$('#id-submit').click(function () {
var allInputs = $(":input");
$(allInputs).value.toUpperCase();
alert(allInputs);
});
This question is related to
javascript
jquery
html
use css :
input.upper { text-transform: uppercase; }
probably best to use the style, and convert serverside. There's also a jQuery plugin to force uppercase: http://plugins.jquery.com/plugin-tags/uppercase
$('#id-submit').click(function () {
$("input").val(function(i,val) {
return val.toUpperCase();
});
});
You can use each()
$('#id-submit').click(function () {
$(":input").each(function(){
this.value = this.value.toUpperCase();
});
});
Use css text-transform to display text in all input type text. In Jquery you can then transform the value to uppercase on blur event.
Css:
input[type=text] {
text-transform: uppercase;
}
Jquery:
$(document).on('blur', "input[type=text]", function () {
$(this).val(function (_, val) {
return val.toUpperCase();
});
});
Source: Stackoverflow.com