surreal53 Posted February 10, 2012 Report Share Posted February 10, 2012 I've written a form validation script to check if a text field contains either M or F as a value. If it contains anything else but the values M or F it should create an alert (Not a valid entry). For some reason the alert pops up for any value that is typed into the field even M or F. Any idea what I'm doing wrong? function ValidateS() { var s1=Xrm.Page.getAttribute("new_s").getValue() -0; if (s1!="F" || s1!="F") { alert("That is not a valid entry"); return false; }} Link to comment Share on other sites More sharing options...
justsomeguy Posted February 10, 2012 Report Share Posted February 10, 2012 Why are you subtracting 0 from the value? Have you alerted the value to verify you're testing what you think you are? Your condition is also checking twice for "F", and that should be an AND instead of OR. Link to comment Share on other sites More sharing options...
t50409143 Posted February 11, 2012 Report Share Posted February 11, 2012 You are saying that if the input doesn't equal F or F then make the popup. You are checking for F twice. Why are subtracting zero?Try this and tell us the result:alert(s1);I have a feeling that s1 is null or something. Link to comment Share on other sites More sharing options...
surreal53 Posted February 13, 2012 Author Report Share Posted February 13, 2012 Thanks, yes this solved the issue: function ValidateS() {var s1=Xrm.Page.getAttribute("new_s").getValue(); if (s1!="F" && s1!="M") { alert("That is not a valid entry"); return false; }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now