views:

133

answers:

1

Hi I got a form for the first name and last name in my flash website For the two fields I defined them as not null but when you just click the spacebar and click on submit its taking it Can some one please help me how do I write the validation for not taking space bar as an Input and and the field should not be empty (Note: I am using actionscript 2.0)

_validateParams[pCnt++] = { type: "notNull",  input: win.firstNameInput , isSendData:true, dataName:"firstName"};
  _validateParams[pCnt++] = { type: "notNull",  input: win.lastNameInput, isSendData:true, dataName:"lastName"};
+1  A: 

I am unsure how to write it in ActionScript, but what you can do is, you could write a trim() routine(or use one that is available) which would remove leading and trailing whitespace, and then check if the resulting string length is 0. This would also remove only spaces if that is the only input that the user had typed.

Thiyagaraj
Hi I dont mind if there is whitespace at the end or inthe begining but if the user just enter spacebar and leave the whole field empty and submit it should not take it as the out put will be nothing
raj
he doesn't mean permanently remove it. Just to check if the field is "empty".
Glenn
I am new to flash can you please give me how the code would be roughly
raj
We would need precise requirements then, do you mean that having 2 spaces is valid then, or having only spaces, no matter the number is invalid?? Depending on that we can give a proper solution.
Thiyagaraj