Question

i have two TextBoxes with the class store on one and banner on another. i managed to get a watermark without using the value="" but i was wondering is there a way to have an on submit action if textbox value is not an int to make value of the textbox an empty string? im still really new to all this. thx in advance. btw i am trying to put this on an mvc4 page.

Was it helpful?

Solution

I'm assuming .net at the very least due to the mvc4 comment.

Are you looking to interpret non-ints to be the empty string?

string i = "123";
string j = "ft1b";

int temp;

i = int.TryParse(i, out temp) ? i : ""; 

if you need to do this in javascript, you can use the isNaN() function instead of TryParse

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top