469,337 Members | 6,367 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

insert data with validation

57
Sir
I face a problem.please help me. my problem is

i have to insert phone no. or a/c id in same field. i have to use two text box. one for phone no. another for a/c id. if i enter phone no. then a/c id disable. no input accept in a/c id textbox. same as phone no., when i entry a/c id then no phone no. entry allowed. On time only one entry allow. another is disable.

Please help me.

Thanks
Mar 30 '08 #1
11 1838
hsriat
1,654 Expert 1GB
Do that with JavaScript.[html]<input type="text" name="phone" id="ph" onkeyup="document.getElementById('ac').disabled = !!this.value.length;">
<input type="text" name="account" id="ac" onkeyup="document.getElementById('ph').disabled = !!this.value.length;">[/html]
Mar 30 '08 #2
ronverdonk
4,258 Expert 4TB
This is a JS question and belongs in the JavaScript forum, so I will move it to that.

Ronald
Mar 30 '08 #3
very intrestng..
But sir why we are setting its value to
Expand|Select|Wrap|Line Numbers
  1. !!this.value.length;
what does it means.
Mar 30 '08 #4
hsriat
1,654 Expert 1GB
very intrestng..
But sir why we are setting its value to
Expand|Select|Wrap|Line Numbers
  1. !!this.value.length;
what does it means.
You mean the double NOT?
It will work without the double NOT too. Its not mandatory.

Double NOT just makes sure the result is boolean.
!!0 returns false
!!n returns true (where n is any number)
Also works on strings.
Mar 30 '08 #5
You mean the double NOT?
It will work without the double NOT too. Its not mandatory.

Double NOT just makes sure the result is boolean.
!!0 returns false
!!n returns true (where n is any number)
Also works on strings.
Thanks for the response.
But its not working on single not.
if the purpose of its to set a boolean value then
why its not working in like below.

<input type="text" name="phone" id="ph" onkeyup="document.getElementById('ac').disabled = true;">
<input type="text" name="account" id="ac" onkeyup="document.getElementById('ph').disabled = true;">
Mar 30 '08 #6
You mean the double NOT?
It will work without the double NOT too. Its not mandatory.

Double NOT just makes sure the result is boolean.
!!0 returns false
!!n returns true (where n is any number)
Also works on strings.
Thanks for the response.
But its not working on single not.
if the purpose of its to set a boolean value then
why its not working in like below.

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="phone" id="ph" onkeyup="document.getElementById('ac').disabled = true;">
  2. <input type="text" name="account" id="ac" onkeyup="document.getElementById('ph').disabled = true;">
Mar 30 '08 #7
hsriat
1,654 Expert 1GB
What are you trying to do? What is the purpose?

If you got a similar problem, tell me that.
Mar 30 '08 #8
malav123
217 100+
HI,
call the javascript function for both textboxes...like,
Expand|Select|Wrap|Line Numbers
  1. txtDayphone.Attributes.Add("Onkeypress", "return formatPhoneNumber(this)")
and check there if one of the textbox gets keypress at the same time remaining text box gets disable to data entry...... i think by implementing this your problem will be solved...


-malav.
Mar 31 '08 #9
gits
5,390 Expert Mod 4TB
HI,
call the javascript function for both textboxes...like,
Expand|Select|Wrap|Line Numbers
  1. txtDayphone.Attributes.Add("Onkeypress", "return formatPhoneNumber(this)")
...
this is no javascript-code ... it seems to be some .NET stuff ... please don't mess different things here ... to set an attribute to a node the regular javascript-dom-method is:

Expand|Select|Wrap|Line Numbers
  1. node.setAttribute('attrib_name', 'attrib_value');
to attach event-handlers you have different possibilities ... write it to the node directly:

[HTML]<input type="button" onclick="alert('clicked me');" value="click me"/>[/HTML]
or use addEventListener() and attachEvent() for this, or set the event-handler-properties like:

Expand|Select|Wrap|Line Numbers
  1. node.onclick = function() { alert('something') };
and: Use code tags when posting Source Code!!!!!

kind regards
Mar 31 '08 #10
malav123
217 100+
this is no javascript-code ... it seems to be some .NET stuff ... please don't mess different things here ... to set an attribute to a node the regular javascript-dom-method is:

Expand|Select|Wrap|Line Numbers
  1. node.setAttribute('attrib_name', 'attrib_value');
to attach event-handlers you have different possibilities ... write it to the node directly:

[HTML]<input type="button" onclick="alert('clicked me');" value="click me"/>[/HTML]
or use addEventListener() and attachEvent() for this, or set the event-handler-properties like:

Expand|Select|Wrap|Line Numbers
  1. node.onclick = function() { alert('something') };
and: Use code tags when posting Source Code!!!!!

kind regards





No gits, my intense is not to giving .net stuff here but i just giving logic to solve the problem of current post...
the code for javascript for this post is quite simple that's why i have not write here....
Mar 31 '08 #11
gits
5,390 Expert Mod 4TB
you posted that repeatedly here in the javascript-forum ... and since .NET stuff is NOT javascript you either should explicitly mark the code as NON-javascript-code with a comment or a note or just translate it to javascript ... there is no reason to write code in another language in a specific forum ... i wouldn't even post a java-solution in the .NET forum and say thats the logic ... translate it yourself ... that is NOT appropriate and i will delete further posts of you here with such behaviour ... remember this!

regards,
MODERATOR
Mar 31 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Ricardo | last post: by
5 posts views Thread by Chris | last post: by
reply views Thread by Eustice Scrubb | last post: by
3 posts views Thread by Mukesh | last post: by
2 posts views Thread by subramanian100in | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.