| | |
validation help
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 22
Reputation:
Solved Threads: 0
I have a text box in a form that is validated to accept a value called ds01 but i also want the textbox to be allowed to accept empty spaces that is if nothing is entered in the textbox. The problem is that it does not accept anything other than ds01. Thanx in advance for your help. This is my script
JavaScript Syntax (Toggle Plain Text)
function validate_choice(field,alerttxt) { with (field) { if (value != "ds01") { alert(alerttxt);return false; } else if (value ==null || value == "" || value=="ds01") { return true; } } } function validate_form(thisform) { with (thisform) { if (validate_choice(webdev, "You Must Enter the Correct Code.Please Enter ds01!.Thank You!")==false) {webdev.focus();return false;} } }
Last edited by peter_budo; Sep 27th, 2009 at 8:27 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
•
•
I have a text box in a form that is validated to accept a value called ds01 but i also want the textbox to be allowed to accept empty spaces that is if nothing is entered in the textbox. The problem is that it does not accept anything other than ds01. Thanx in advance for your help. This is my script
function validate_choice(field,alerttxt)
{
with (field)
{
if (value != "ds01")
{
alert(alerttxt);return false;
}
else if (value ==null || value == "" || value=="ds01")
{
return true;
}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_choice(webdev, "You Must Enter the Correct Code.Please Enter ds01!.Thank You!")==false)
{webdev.focus();return false;}
}
}
function validate_choice(field,alerttxt){
with (field){
if (value ==null || value == "" || value=="ds01"){
return true;
}
else if (value != "ds01"){
alert(alerttxt);
return false;
}
}
}*the part in red is not needed, but doesn't cause problems...
![]() |
Similar Threads
- W3C Validation (HTML and CSS)
- .net validation/javascript conflict (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: doubt with client side javascripting
- Next Thread: help with two column dynamic table sum
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha microsoft mimic object onerror onmouseoutdivproblem onreadystatechange parent pdf php player post problem progressbar rated rating regex runtime scroll search security select session shopping size software sql star stars synchronous text textarea unicode validation w3c web website window windowofwords windowsxp wysiwyg xml \n





