Make string uppercase before dash

1

How can I convert a string to uppercase before a dash (-) as it is typed using jQuery / JavaScript?

Example text: "ab- Hello world cx- Okay?"

Output: AB- Olá mundo CX- Tudo bem?

//
$('textarea').keyup(function(){
   $(this).val( ? );
});
    
asked by anonymous 24.09.2014 / 14:20

2 answers

2

You can do this:

$('textarea').keyup(function(){
   var mystr = $(this).val();
   var myarr = mystr.split("-");
   var myvar = myarr[0].toUpperCase() + "-" + myarr[1];
});

Using split to separate values and toUpperCase to make uppercase.

Remembering that this solution was made for a single -

    
24.09.2014 / 14:30
0

Resolved

function beforeDash( val ){
    return val.replace(/(?:\w+-)/g, function(match){
        return match.toUpperCase()
    });
}
    
14.11.2014 / 15:25
___ ___ erkimt Error adding HttpPost the controller ______ qstntxt ___

I have a problem in time to add the attribute %code% on my controller. I mean, I can add the attribute without problems, but when I compile and go to the form registration I just can not access.

I get the following error:

  

Server Error in Application '/'.

     

Can not find the resource.

     

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could not be removed, had its name changed, or is temporarily unavailable. Examine the URL and make sure that it is spelled correctly.

     

requested URL: / User / add

Version Information: Microsoft .NET Framework Version: 4.0.30319; ASP.NET:4.0.30319.33440

Also, when I take %code% % attribute, I can not see the registration form, but I can not do the insert in the bank.

    
______ ___ azszpr31034

When you add the HttpPost attribute in an action. It can only be accessed via the HTTP POST method.

If your intention is to only display the form. Do not decorate your method with no attributes, the default is GET.

What you can do is set an Add method with no attribute. This method will be accessed via GET and display the form.

Then you create a second method, for example AdicionarConfirmado, decorated with the attributes and HttpPost ActionName="Add"

The methods can no defined as follows

%pre%

Since your form that will save the record would look like this:

%pre%     
___
How to disable all TextView in an Activity?